Does any one know how to create macro variable with sas macro process to get specific day of week ?
I would like to get Wednesday date of the previous week every time I run the sas macro.
For example :
Today : Tuesday Oct 18,2011--> if I run the macro today I would like to get : "Wednesday Oct 12, 2011"
and If I run the macro on Monday , I still want to get the "Wednesday Oct 12, 2011"
Thanks,
If you want to call a macro to return the date of the most recent Wednesday. (Also, if you want the date just stored in a macro var...remove the "&weekday;" statement.)
%Macro Get_Weekday(date);
%Let weekday=%sysfunc(putn(
%sysfunc(intnx(week.4,&date,0,beginning)),weekdate.));
&weekday;
%Mend Get_Weekday;
%Put Today is %sysfunc(putn(%sysfunc(today()),weekdate.))
and the most recent Wednesday is %Get_Weekday(%sysfunc(today()));
%Put If Today was %sysfunc(putn(%eval(%sysfunc(today())-1),weekdate.))
then the most recent Wednesday would be
%Get_Weekday(%eval(%sysfunc(today())-1));