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?
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.