I have a SAS dataset called "holidays" that is structured as shown below that spans 1985-2023. I have dummy variables for the Friday and the weekend, and most importantly holidays.
I am trying to write a loop which works through a list of all months and days of the week to determine what percentage of a day of the week, for a given month, falls on a holiday. For instance, what percentage of Monday's in January have been a federal holiday between 1985 and 2023? What percentage of Tuesday's in January, etc... Below is my code thus far:
%let m_list = 1 2 3 4 5 6 7 8 9 10 11 12;
%let d_list = 1 2 3 4 5 6 7;
%macro holidays(list1,list2);
%local month day next_month next_day;
%do month = 1 %to %sysfunc(countw(&m_list));
%let next_month = %scan(&m_list,&month);
%do day = 1 %to %sysfunc(countw(&d_list));
%let next_day = %scan(&d_list,&day);
proc freq data = holidays;
where Month = &next_month and dow = &next_day;
table HolDum / out = prob_&next_month._&next_day;
data _null_;
set prob_&next_month._&next_day;
if HolDum = 0 then call symput("M&next_month._&next_day._0",PERCENT/100);
else if HolDum = 1 then do;
call symput("M&next_month._&next_day._1",PERCENT/100);
end; run;
%end;
%end;
%mend holidays;
%holidays(&m_list,&d_list)
%put &M1_1_0 &M1_1_1 &M1_2_0 &M1_2_1;
Where I am stuck is the data _null_ step--the loop does not seem to be assigning percentages for the holiday dummy variable to the variable name (as verified when I run the %put statement). Can someone help me troubleshoot this. I'm relatively new to SAS so this might be a SAS issue I'm not seeing, or perhaps just a logic issue I'm missing. Thanks.
... View more