Wow--thank you Reeza for such a comprehensive answer. I will work through this and update you on the result. The version of SAS Enterprise Guide that I am using is more of a GUI/low code environment so I have not written any custom programs. I've already learned a lot--syntax especially--from the snippet of code to recreate the two rows of data. Thank you again, I am diving into this today.
You likely also need to account for Spring Break, so you can add your custom holidays within my logic in the first step - basically add in the extra University closures you need to add.
Not accounting for holidays, you can do it like this:
data want;
set have;
array week(*) Sunday--Saturday;
days=0;
do _N_=1 to dim(week);
if week(_N_) then
days+intck(cats('week.',_N_),bannerStartDate-1,bannerEndDate);
end;
run;
The INTCK function counts the number of Sundays passed with first parameter=WEEK.1, Mondays with WEEK.2, etc. We have to subtract one from the first date in case the period starts on a relevant day.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.