- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have the following dataset. What I would like to do is that set the final_stop_date_time to be the midnight of the start_date_time
patientID | start_date_time | stop_date_time | |
1 | 1/2/2019 1:40 | 1/2/2019 22:59 | |
2 | 2/3/2019 1:40 | ||
3 | 4/4/2019 1:40 | 4/4/2019 23:59 |
To this:
patientID | start_date_time | stop_date_time | final_stop_date |
1 | 1/2/2019 1:40 | 1/2/2019 22:59 | 1/2/2019 23:59 |
2 | 2/3/2019 1:40 | 2/3/2019 23:59 | |
3 | 4/4/2019 1:40 | 4/4/2019 23:59 | 4/4/2019 23:59 |
i tried
intcx and intx but i couldn't get to set to midnight. any helpful would be great!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Something like this should work:
data want;
set have;
final_stop_date_time=intnx('dtday',stop_date_time,0,'e');
run;
Art, CEO, AnalystFinder.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Something like this should work:
data want;
set have;
final_stop_date_time=intnx('dtday',stop_date_time,0,'e');
run;
Art, CEO, AnalystFinder.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! It worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
> i tried intcx and intx but i couldn't get to set to midnight. any helpful would be great!
Just a terminology point: You don't really want midnight.
Midnight is generally considered 00:00 of the next day (or 12.00 am of the next day in the crazy am pm system), rather than 24:00 of the current day.
So @art297 's solution gives what you actually want and what you showed: the last moment of the current day.
Also note that there are ways to alter this convention in SAS, such as the DATATYPE=DATETIME_UTIL option for the picture format, which ends the day at 24:00.