Your input dataset should be work.compno_date_list
, not work.date_list
.
proc sql noprint; select distinct sdate into : sdatem separated by ' ' from work.compno_date_list; quit; %put &sdatem;
Question
I am new to macro writing in SAS and being a proficient R user, I am having a difficult time understanding how to do things in SAS. I am trying create a macro variable that contains the list of dates from a dataset.
My code is -
proc sql noprint;
select distinct sdate into : sdatem separated by ' '
from work.date_list;
quit;
%put &sdatem;
But when I run this code, the code is executed without any errors but the %put statement in the log prints
%put &sdatem;
and not the actual value. Any idea why this is happening? The dates are in yymmddn8. format.
The sample data I used is -
DATA compno_date_list;
INPUT compno sdate;
DATALINES;
12490 20090120
87432 20090120
24643 20090120
87432 20090119
12490 20090105
24643 20090105
;
proc print data=compno_date_list;
run;
Any help would be great! Thanks
Solution
Your input dataset should be work.compno_date_list
, not work.date_list
.
proc sql noprint; select distinct sdate into : sdatem separated by ' ' from work.compno_date_list; quit; %put &sdatem;