50 data test;
51 infile 'employee';
52 input employee_name $ 1-4;
53 if employee_name = 'Sue' then input age 7-8;
54 else input idnum 10-11;
NOTE: The infile 'C:\mysaslib\Elance_Angela\employee' is:
RECFM=V,LRECL=256,File Size (bytes)=52,
NOTE: 4 records were read from the infile 'C:\mysaslib\Elance_Angela\employee'.
The minimum record length was 11.
The maximum record length was 11.
NOTE: The data set WORK.TEST has 2 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
The processing of the data file as it reads in will be as follows:
1. SAS reads the first line when the first input statement is executed: input employee_name $ 1-4; and reads the value as "Ruth."
2. SAS executes the next statement, if employee_name = 'Sue' ' then input age 7-8; and since the value for employee_name = 'Ruth,' the condition is false and SAS reads the second input statement, input idnum 10-11. SAS looks for the second line in the data file and assigns a value of 22 to idnum.
3. For the next iteration of the data step, SAS reads the value 'Sue' for employee_name.
4. The IF condition will be true this time when SAS executes the statement else input age 7-8; and for this input statement, SAS reads the value at the fourth line at column 7-8 and assigns age a value of 40.
To read the file correctly, the following program is required:
input employee_name $1-4 @;
if employee_name = 'Ruth' then input age 7-8;
else input idnum 10-11;
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.