BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
prianca
Calcite | Level 5

i need to find out the months in which 4 sunday and 4 saturday are there in the last three years

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.)

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

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.

FreelanceReinh
Jade | Level 19

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.)

prianca
Calcite | Level 5

find out the months in which last days are weekends????

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1318 views
  • 4 likes
  • 3 in conversation