Another option is to add βsplitβ into sql code, which will add a separator to the values. Then you can use the SCAN function in the data step or% SCAN in the macro to iterate over the values ββand perform any task you want. An example is below.
proc sql noprint; select age into :age separated by ',' from sashelp.class; quit; %put &age.; data test; do i=1 by 1 while(scan("&age.",i) ne ''); age=scan("&age.",i); output; end; drop i; run;
source share