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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1559 views
  • 0 likes
  • 4 in conversation