BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Krysia24
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20



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;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20



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;
Barkat
Pyrite | Level 9
Here the week_start starts on Sunday. How can I modify the code, so the week_start starts on Saturday?
Barkat
Pyrite | Level 9
I found that.

data Want;
set have;
Week_start=intnx('Week.7',date,0,'b');
format Week_start mmddyy10.;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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
  • 3 replies
  • 8561 views
  • 1 like
  • 3 in conversation