In the previous example, we used the less-than sign to make the comparison. We can use any of the standard comparison operators to make our comparisons as long as we follow the syntax that SAS expects, which is:
Comparison | SAS syntax | Alternative SAS syntax |
---|---|---|
less than | < | LT |
greater than | > | GT |
less than or equal to | <= | LE |
greater than or equal to | >= | GE |
equal to | = | EQ |
not equal to | ^= | NE |
equal to one of a list | in | IN |
It doesn't really matter which of the two syntax choices you use. It's just a matter of preference. To convince yourself that you understand how to use the alternative SAS syntax though, replace the less-than sign (<) in the Example 5.1 program with the letters "LT" (or "lt"). Then, re-run the SAS program and review the output from the PRINT procedure to see that the program indeed performs as expected.
Example 5.2 Section
The following SAS program uses the IN operator to identify those students who scored a 98, 99, or 100 on their project score. That is, students whose p1 value equals either 98, 99, or 100 are assigned the value 'Excellent' for the project variable:
DATA grades;
input name $ 1-15 e1 e2 e3 e4 p1 f1;
if p1 in (98, 99, 100) then project = 'Excellent';
DATALINES;
Alexander Smith 78 82 86 69 97 80
John Simon 88 72 86 . 100 85
Patricia Jones 98 92 92 99 99 93
Jack Benedict 54 63 71 49 82 69
Rene Porter 100 62 88 74 98 92
;
RUN;
PROC PRINT data = grades;
var name p1 project;
RUN;
Launch and run the SAS program and review the output from the PRINT procedure to convince yourself that the program performs as described.