169 data projectduration;
170 infile 'C:\mysaslib\Elance_Angela\datarecord.txt';
171 input date $ 1 - 10;
172 duration = today( ) - input(date,yymmdd10.);
NOTE: The infile 'C:\mysaslib\Elance_Angela\datarecord.txt' is:
RECFM=V,LRECL=256,File Size (bytes)=10,
NOTE: 1 record was read from the infile 'C:\mysaslib\Elance_Angela\datarecord.txt'.
The minimum record length was 10.
The maximum record length was 10.
NOTE: The data set WORK.PROJECTDURATION has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
Dates are stored in SAS as a number (just as they are in Excel). Since we are reading the value 1999/10/25 as a character, it has YYMMDD format. We need to convert it to a number while calculating the duration variable.
Option A and Option B both use the PUT function, but this is used to convert a value from numeric to character with a specified format. So these options are incorrect.
The INPUT function will convert a value from character to numeric with a given informat. The correct informat to convert the date string to a number is YYMMDD10. Option D uses this informat so it is correct answer.
The one and only FREE resource for general SAS online training as well as study guides for the SAS Base Certification. My goal is to create the SAS Certification prep guide that I never found but always wanted. This should also be a place to come if you are new to the language but are simply looking for online SAS training.