Data work.my_data_file; Result_1 = INTNX('dtday','15apr21:00:10:48'dt,1); Result_2 = PUT(Result_1, datetime19.); Result_3 = INTNX('dtsec','15apr21:00:10:48'dt,1); Result_4 = PUT(Result_3, datetime19.); Result_5 = INTNX('dtmin','15apr21:00:10:48'dt,1); Result_6 = PUT(Result_5, datetime19.); Result_7 = INTNX('dthour','15apr21:00:10:48'dt,1); Result_8 = PUT(Result_7, datetime19.); Result_9 = INTNX('day','15apr21:00:10:48'dt,1); Result_10 = PUT(Result_9, date.); Result_11 = INTNX('week','15apr21:00:10:48'dt,1); Result_12 = PUT(Result_11, date.); Result_13 = INTNX('month','15apr21:00:10:48'dt,1); Result_14 = PUT(Result_13, date.); Result_15 = INTNX('year','15apr21:00:10:48'dt,1); Result_16 = PUT(Result_15, date.); Run; |
What's happening in the script above?
Variable | Input | Output | Description |
---|---|---|---|
Result_1 | INTNX('dtday','15apr21:00:10:48'dt,1); | 1934150400 | A SAS numeric representation of the datetime |
Result_2 | PUT(Result_1, datetime19.); | 16Apr2021:00:00:00 | A reformated datetime that has been incremented by 1 day |
Result_3 | INTNX('dtsec','15apr21:00:10:48'dt,1); | 1934064649 | A SAS numeric representation of the datetime |
Result_4 | PUT(Result_3, datetime19.); | 15Apr2021:00:10:49 | Reformatted and incremented by 1 second |
Result_5 | INTNX('dtmin','15apr21:00:10:48'dt,1); | 1934064660 | A SAS numeric representation of the datetime |
Result_6 | PUT(Result_5, datetime19.); | 15APR2021:00:11:00 | Reformatted and incremented to the next minute; notice it is not 60 seconds later |
Result_7 | INTNX('dthour','15apr21:00:10:48'dt,1); | 1934067600 | A SAS numeric representation of the datetime |
Result_8 | PUT(Result_7, datetime19.); | 15APR2021:01:00:00 | Reformatted and incremented to the next hour; notice it is not 60 minutes later |
Result_9 | INTNX('day','15apr21'd,1); | 22386 | Numeric Represenation (NR) |
Result_10 | PUT(Result_9, date.); | 16APR21 | Reformatted and incremented by 1 day |
Result_11 | INTNX('week','15apr21'd,1); | 22388 | (NR) |
Result_12 | PUT(Result_11, date.); | 18APR21 | Incremented to the following sunday (e.g. the next week; not 7 days later) |
Result_13 | INTNX('week','15apr21'd,1); | 22401 | (NR) |
Result_14 | PUT(Result_13, date.); | 01MAY21 | Incremented to the first of the following month |
Result_15 | INTNX('week','15apr21'd,1); | 22646 | (NR) |
Result_16 | PUT(Result_15, date.); | 01JAN22 | Incremented to the first of the following year |
See also; PUT Function
See also; TODAY Function
See also; MYD Function
Kevin Regan
Have an article, idea, found a typo, want to contribute? Shoot me an email
Here
Below are links to some Udemy Data Science Courses. I've been using Udemy for a number of years now, and I've found their courses super helpful, maybe you will also.