Hi all,
I need to calculate SAS dates 3 month before and 3 month after given dates but not adding or subtracting 90 days
For example,
I would like to know the dates (3 month before and after) using the given dates
3 month before | Given date | 3 month after |
10/1/2017 | 1/1/2017 | 4/1/2017 |
11/1/2017 | 2/1/2017 | 5/1/2017 |
12/1/2017 | 3/1/2017 | 6/1/2017 |
Adding or subtracting 90 days do not give me the same dates with different months.
Does anyone know how to calculate these types of dates?
Thanks!
Use the INTNX function:
date_before = intnx("MONTH", date, -3, "SAME");
date_after = intnx("MONTH", date, 3, "SAME");
data want;
set have;
th3mthbfr=intnx('month', givrndate,-3,'s');
th3mthaftr=intnx('month', givrndate,3,'s');
format th3mthbfr th3mthaftr mmddyy10.;
run;
data want;
set have;
th3mthbfr=intnx('month', givrndate,-3);
thrmthaftr=intnx('month', givrndate,3);
run;
Use the INTNX function:
date_before = intnx("MONTH", date, -3, "SAME");
date_after = intnx("MONTH", date, 3, "SAME");
Thanks! It worked.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.