sqlselectsasselect-into

Dynamize range of SAS PROC SQL SELECT INTO macro creation


I want to put multiple observations into an own macro variable. I would do this by using select into :obs1 - :obs4, however, as count of observations can differ, i would like to dynamize the range and my code looks like this:

proc sql;
    create table segments as select distinct substr(name,1,6) as segment from dictionary.columns
    where libname = 'WORK' and memname = 'ALL_CCFS' and name ne 'MONTH';
run;

proc sql noprint;
    select count(*) into: count from segments;
run;

proc sql noprint;
    select segment into :segment_1 - :segment_&count. from dictionary.columns;
run;

However, this doesn't seem to work... any suggestions? Thank you!


Solution