BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Suryak
Calcite | Level 5
data Months;
do i ='01JAN2022'd to '31DEC2022'd;
FirstDayMonth = intnx('month', i,0,'b'); 
output;
do j= '01JAN2022'd to '31DEC2022'd;
EndDayMonth = intnx('month',j,0, 'e'); ; 
output;
drop firstdaycurrmonth enddaycurrmonth;
end;
end;
format _ALL_ weekdate9.;
run;
 
proc print data=Months noobs;
run;

Here i want start weekname and end weekname of each month in a given date range

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Are you looking for something like this? The INTNX function can give you the first/last date of a given period.

data want;
  do month = 1 to 12;
    someDate = mdy(month, 15, 2022);
    startDay = intnx("month", someDate, 0, "B");
    endDay = intnx("month", someDate, 0, "E");
    output;
  end;

  format
    somedate date9.
    startDay endDay weekdate.
  ;
run;

proc print data=want noobs;
run;

View solution in original post

5 REPLIES 5
Suryak
Calcite | Level 5
i want to weekname start weekname and end weekname of each month
ex: This june month weekstarts wednesday endofmonth thursday
BrunoMueller
SAS Super FREQ

Are you looking for something like this? The INTNX function can give you the first/last date of a given period.

data want;
  do month = 1 to 12;
    someDate = mdy(month, 15, 2022);
    startDay = intnx("month", someDate, 0, "B");
    endDay = intnx("month", someDate, 0, "E");
    output;
  end;

  format
    somedate date9.
    startDay endDay weekdate.
  ;
run;

proc print data=want noobs;
run;
Suryak
Calcite | Level 5
YES almost same result

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
  • 1332 views
  • 0 likes
  • 3 in conversation