I have one datetime variable and I would like to add 7 days to the existing date/time
patientID | raw_start_date_time | new_start_date-time |
1 | 12/4/2019 15:21 PM | 12/5/2019 15:21 PM |
2 | 12/5/19 12:42 PM | 12/12/19 12:42 PM |
I did the following and didn't work
new_start_date = intck ('dtday', raw_start_date_time, 7)
I also tried intck('day'), intnx ('day'), and raw_start_date_time * 7 * 24 * 60 * 60.
No luck
INTNX, not INTCK() and dtDAY since you have a datetime.
new_start_date = intnx('dtday', raw_start_date_time, 7);
If you wanted to do it manually you need to ADD that date amount, not multiply it.
raw_start_date_time + 7 * 24 * 60 * 60
INTCK() counts intervals. You want INTNX().
Also are variables really datetime and not string? I don't think SAS has a format to display datetime values in that style you are showing. But perhaps that is data you typed into Excel instead?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.