Previous PageNext Page

Example 1: Brute force recoding
You know how to use an IF-THEN/ELSE structure.

Data Grades;
     Input Score;
     ID = _N_;
     IF       0 LE Score LT 65 THEN Grade='F';
     ELSE IF 65 LE SCORE LT 70 THEN Grade='D';
     ELSE IF 70 LE SCORE LT 80 THEN Grade='C';
     ELSE IF 80 LE SCORE LT 90 THEN Grade='B';
     ELSE IF       SCORE GE 90 THEN Grade='A';
Datalines;

... data omitted

Proc Print;
   Title 'Example 1 Chapter 2';

This is the first use of the assignment statement in SAS code.

Previous PageTable Of ContentsNext Page