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;
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 save with the early bird rate—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.