I would like to have a matrix of binary flags that indicate whether a holiday occurred on the given day, something like this (but with every SAS-recognized holiday):
date flag_BOXING flag_CHRISTMAS flag_... flag_...
14DEC2014 0 0 0 0
15DEC2014 0 0 0 0
16DEC2014 0 0 0 0
17DEC2014 0 0 0 0
18DEC2014 0 0 0 0
19DEC2014 0 0 0 0
20DEC2014 0 0 0 0
21DEC2014 0 0 0 0
22DEC2014 0 0 0 0
23DEC2014 0 0 0 0
24DEC2014 0 0 0 0
25DEC2014 0 1 0 0
26DEC2014 1 0 0 0
27DEC2014 0 0 0 0
28DEC2014 0 0 0 0
I know there is probably an easier way to do this, but wanted to make sure before I continue through with my current attempt (which does not actually work....). I was thinking of creating a separate column that brings in the date of the actual holiday, then if that date matches the day on the specific row, the flag variable becomes a 1. The downside to this is that I would have to do this for every holiday. Also, the holiday function requires a year specification, so I would have to use some if-elseif logic to account for different years (my list is several years of dates). Is there an easy way to produce the matrix I want or is this the best way to proceed?
data test;
length day $9;
input day $;
cards;
23DEC2014
24DEC2014
25DEC2014
26DEC2014
27DEC2014
28DEC2014
;
run;
data test(drop=BOXING CHRISTMAS);
set test;
BOXING=holiday('boxing', 2014);
CHRISTMAS=holiday('christmas', 2014);
format BOXING CHRISTMAS date9.;
flag_BOXING=0;
flag_CHRISTMAS=0;
if upcase(day)=upcase(BOXING) then flag_BOXING=1;
if upcase(day)=upcase(CHRISTMAS) then flag_CHRISTMAS=1;
run;
Thanks.