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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Update

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
  • 1334 views
  • 4 likes
  • 3 in conversation