i need to find out the months in which 4 sunday and 4 saturday are there in the last three years
Hello @prianca and welcome to the SAS Support Communities!
You can use the NWKDOM function:
data want;
do y=2016 to 2018;
do m=1 to 12;
if (nwkdom(4,1,m,y)=nwkdom(5,1,m,y))
& (nwkdom(4,7,m,y)=nwkdom(5,7,m,y)) then output;
end;
end;
run;
(This assumes that you mean "exactly 4 Sundays and exactly 4 Saturdays" -- otherwise the task would be trivial, after all.)
For every possible month length (31/30/29/28 days), determine the weekdays on which the first has to fall for the condition to be true.
Then do a loop over months and look if the first falls on one of these weekdays.
Hello @prianca and welcome to the SAS Support Communities!
You can use the NWKDOM function:
data want;
do y=2016 to 2018;
do m=1 to 12;
if (nwkdom(4,1,m,y)=nwkdom(5,1,m,y))
& (nwkdom(4,7,m,y)=nwkdom(5,7,m,y)) then output;
end;
end;
run;
(This assumes that you mean "exactly 4 Sundays and exactly 4 Saturdays" -- otherwise the task would be trivial, after all.)
... and every now and then, Maxim 9 does an end-around on me 🙂
find out the months in which last days are weekends????
where weekday(intnx('month',mdy(month,1,year),0,'e')) in (1,7);
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.