BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hjjijkkl
Pyrite | Level 9

How do you subtract weeks from a given date? how can i code that

for example I have a data with a date (date1 ) and I want to subtract 36 weeks and get a new date (date2). please look the table below for example.

date1             date 2

5/3/2012       8/25/2011

6/4/2012        9/26/2011

1 ACCEPTED SOLUTION
4 REPLIES 4
hjjijkkl
Pyrite | Level 9
Meaning subtracting 36 weeks from date1 to get date 2
PaigeMiller
Diamond | Level 26

Another way to do this is to suntract 36*7 from each date.

--
Paige Miller
ballardw
Super User

How many times has it been suggested to you to provide data in the form of a data step?

For one thing, we need to know if the values are actually SAS data values or not.

This shows adjusting a date by 36 weeks to the Same day of the week, Beginning of the week or End of the week.

 

data have;
   input date1 :mmddyy10.;
datalines;
5/3/2012      
6/4/2012
; 

data want;
   set have;
   date2= intnx('week',date1,-36,'s');
   date3= intnx('week',date1,-36,'b');
   date4= intnx('week',date1,-36,'e');
   format date: mmddyy10.;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1863 views
  • 0 likes
  • 4 in conversation