Creating a series of dummy variables

Thanks Russ:

Based on the lowest and highest grade, the following creates a series of dummy variables indicating which grade level is served --- by schools.

data one;
input ID LOWEST_GRADE HIGHEST_GRADE;
cards;
1 4 9
2 9 12
;

data new;
array grades(*) grade1-grade12;
set one;
do i =1 to dim(grades);
if i ge lowest_grade and i le highest_grade then grades(i)=1;
else grades(i)=0;
end;
run;

proc print;
run;

Leave a Reply