I have a date variable and I want to be able to calculate its corresponding week start date. Example:
Have:
Date
1/5/2020
1/6/2020
1/7/2020
1/12/2020
1/21/2020
1/23/2020
Want:
Date: Week Start Date:
1/5/2020 1/5/2020
1/6/2020 1/5/2020
1/7/2020 1/5/2020
1/13/2020 1/12/2020
1/21/2020 1/19/2020
1/23/2020 1/19/2020
data have;
input date :mmddyy10.;
format date mmddyy10.;
cards;
1/5/2020
1/6/2020
1/7/2020
1/12/2020
1/21/2020
1/23/2020
;
data Want;
set have;
Week_start=intnx('Week',date,0,'b');
format Week_start mmddyy10.;
run;
data have;
input date :mmddyy10.;
format date mmddyy10.;
cards;
1/5/2020
1/6/2020
1/7/2020
1/12/2020
1/21/2020
1/23/2020
;
data Want;
set have;
Week_start=intnx('Week',date,0,'b');
format Week_start mmddyy10.;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.