![]() ![]() Let’s say we have the same dataset as above. With the SAS intnx(), we can easily adjust dates to the beginning, middle or end of an interval with the ‘alignment’ argument. Let’s add and subtract time from each of these variables – let’s add 1 day, add 3 months, add 2 years, and substract 4 weeks from each of the dates. Let’s say we have the following SAS dataset with some date variables. The ‘interval’ is the interval you want to add or subtract (seconds, minutes, hours, days, weeks, months, years), ‘start-from’ is the date you will adjust, ‘increment’ is how many intervals you want to add or subtract, and ‘alignment’ is if you want to align the date to the beginning, middle, or end of the interval. In addition, we can adjust dates to the beginning or end of an interval if necessary.įrom the documentation, the SAS intnx() function takes 3 arguments, ‘interval’, ‘start-form’, and ‘increment’, with an optional fourth argument ‘alignment’. ![]() We can add and subtract time by a given interval (second, minute, hour, day, week, month, year). The SAS intnx() function allows us to add and subtract time very easily. When working with dates in our data, it’s very useful to be able to easily add or subtract time to our date variables. data data_new ĭate_plus_1_day = intnx('day', date_variable, 1, 'same') ĭate_plus_1_mon = intnx('month', date_variable, 1, 'same') ĭate_plus_1_yr = intnx('year', date_variable, 1, 'same') To add or subtract time from a date in a SAS data step, we can use the SAS intnx() function. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |