86 data work.flights;
87 destination = 'cph';
89 when('LHR') city = 'London';
90 when('CPH') city = 'Copenhagen';
91 otherwise city = 'Other';
NOTE: The data set WORK.FLIGHTS has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
The statement destination = 'cph'; assigns a value of 'cph' for the variable destination. The variable city first appears in the statement when('LHR') city = 'London'; wherein the SAS compiler sets a length of 6 for the variable city. The length can only be altered by specifying an explicit length using the LENGTH statement as the first line of the data step. For the statement when('CPH') city = 'Copenhagen';, the condition is found to be false because the string comparison is case sensitive ('CPH' versus 'cph'). Thus, the statement otherwise city = 'Other'; assigns a value of 'Other' to the variable city.
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.