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
Use the INTNX function with a 'week' interval.
Use the INTNX function with a 'week' interval.
Another way to do this is to suntract 36*7 from each date.
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;
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.