0
votes

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

1
If your code has run with errors recently it may have set the OBS= option to zero. Try running OPTIONS OBS=MAX NOSYNTAXCHECK; and then run the code again.mjsqu
Tried this. But it still doesn't work.RHelp
Is the line below the %put statement completely blank?mjsqu
yes. You mean in the code or in the log? Both are blanksRHelp
What is returned in the log by the statement %put foo &sdatem bar;?mjsqu

1 Answers

2
votes

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;