29 data work.example;
31 if a=1 then b=100;
32 if a=2 then b=200;
33 if a=3 then b=300;
34 else b=27;
NOTE: The data set WORK.EXAMPLE has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
The ELSE statement is only dependent upon the last IF statement. The first two IF statements in the example code do not have an associated ELSE statement and are totally independent of each other or the third IF statement. Given a equals 2, the b value is assigned a value of 200 by the second IF statement. Then, because a does not equal 3, the third IF statement's condition is false, the ELSE statement is executed, and a value of 27 is assigned to b . The final values are: a=2, b=27.
This is visible in the final Work.EXAMPLE dataset:
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.