I have a SAS file that stores students course selection (up to 20 fields) and grades for each course (up to 20 fields) for a certain semester. To set the sas working file, I use the follow data step. Both course variables and grades variables have the common prefix “crs” and “grade”. It is more efficient to list the 20 course variables using “crs1-crs20” than list each and every one of them.
%let varlist = crs1-crs20 grade1-grade20 studentid major;
Data tem1;
Set coursefile_fw16 (keep = &varlist.);
run;