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
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;
Weeks have no names, only numbers. Or do you mean the weekday of a given date?
WEEKS DO NOT HAVE NAMES.
So the word "weekname" makes no sense.
Please show which value(s) you have, and what you want to get from it
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.