So I am a little rusty on macros -- Below two things happen -first I output a dataset with dates (Thanks @Reeza - I took this from you) . The next part I am using the dataset to attempt to output to a text file-
Once I figure out how to do it, I can expand on what I need to do-for now I just can't figure how to successfully capture the observations - TIA.
data arghh;
Do year=2013 to 2016;
Do month=1 to 12;
n='N'||COMPRESS(PUT(MONTH,8.)||PUT(YEAR,8.));
Date1=mdy(month, 1, year);
date2=intnx('month',date1,0,'end');
date1T=put(date1,ddmmyy.);
date2T=put(date2,ddmmyy.);
Output;
End;
End;
format date1 date9. date2 date9.;
run;
%macro roller(data=, var=,var1=,var2=);
proc sort data=&data(keep=&var &var1 &var2) out=values nodupkey;
by &var ;
run;
data _null_;
file 'test2.txt';
set values end=last;
call symputx('siteA'||left(_n_),&var);
call symputx('DateA'||left(_n_),&var1);
call symputx('DateB'||left(_n_),&var2);
if last then call symputx('countx',_n_,'g');
run;
select(&var);
%do i=1 %to &countx;
%PUT "A &siteA&i";
%PUT "A &&DateA&i";
%PUT "B &&DateB&i";
run;
file print; /*doesn't seem to work here*/
%END;
%MEND roller;
%roller(data=arghh, var=N,var1=date1T,var2=date2T);
... View more