Thank you so much for your reply. I try to use the first code but it didn't work. SAS notifies error: More positional parameters found than defined. libname myLib "C:\"; %macro table_creation (d=); rsubmit; libname comp '/sasdata/file';
proc sql;
create table INFO as
select A.ID,
A.DATADATE,
A.COMPNAME,
A.SALES,
A.PRM,
A.FYEARQ
from STATISTIC A
where ID in ('011636', '014489')
and intnx(month,"&d."d,-3) <= datadate <= "&d."d; quit; proc download data= INFO out=myLib.example; run; endrsubmit; proc export DATA=myLib.example OUTFILE="C:\&d.dta" DBMS=dta REPLACE; run;
%mend table_creation;
%table_creation (31DEC2016); I have another small question if you don't mind. How can I create the loop to create table for each month over a particular time period (let's say 31DEC1970 to 31DEC2016) and export to the .dta file monthly (name that month and year) with SAS Code above ? I really appreciate that.
... View more