Hi Community,
I have a dataset where I need only to change the red vs2 date to a day later (in below the first vs2 date really should be 24APR2015:00:06:00) and the last vs2 date really should be 22NOV2017:00:04:00, while the other dates should remain the same.
How should I handle situation like this? Thanks as always
vs1 | vs2 |
23APR2015:23:51:00 | 23APR2015:00:06:00 |
05MAY2015:13:00:00 | 05MAY2015:12:59:00 |
06JUN2015:18:52:00 | 06JUN2015:18:52:00 |
23AUG2015:23:32:00 | 23AUG2015:23:30:00 |
10SEP2015:20:39:00 | 10SEP2015:20:32:00 |
23SEP2015:21:48:00 | 23SEP2015:21:44:00 |
07DEC2015:12:45:00 | 07DEC2015:12:27:00 |
21NOV2017:23:40:00 | 21NOV2017:00:04:00 |
Do you mean you want to make the change if vs2 is more than an hour before vs1?
if vs1 - vs2 > 3600 then vs2 = intnx('dtday',vs2,1,'s');
Is there logic for why those two need to change? Or do you just want to test for any value on those dates?
Thank you for inquiring, those values in red are the correct values, basically vs2 should start a few minutes after vs1, so the situation is vs1 and vs2 just happens to cross the midnight, while the other values have issues which I don't want to program to change, they need further investigation
How do you identify the dates that need to be changed?
The function for calculation of intervals is intnx(). Use "dtday" as interval.
Thanks for inquiring. I plan to use
vs1_2 = INTCK('hour',vs2,vs1);
vs1_2 = 23;
to indentify those values across the midnight.
Do you mean you want to make the change if vs2 is more than an hour before vs1?
if vs1 - vs2 > 3600 then vs2 = intnx('dtday',vs2,1,'s');
I should add 24 hours to vs2 to bring vs2 one day ahead of its current status, that is my plan, just like to consult the experts here
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.