01jan2020:00:00:00
IF I INCREMENT 1DAY 2HRS 3MINS 4SECS WHAT IS THE OUTPUT? AND HOW TO ADD ?
CAN I GET CODE PLEASE, HIGHLY APPRECIATED...
data example;
datetime='01jan2020:00:00:00'dt;
incremented_datetime= datetime
+ 24*60*60 /* adds one day, in seconds */
+ 2*60*60 /* adds two hours, in seconds */
+ 3*60 /* adds 3 minutes, in seconds */
+ 4 /* adds four seconds */ ;
format datetime incremented_datetime datetime16.;
run;
data test;
dt='01jan2020:00:00:00'dt;
increment=1;
dt=intnx('dtday',dt,increment)+'2:3:4't;
format dt datetime20.;
run;
Durations can be stored as date-time,
34 data _null_;
35 dt = dhms('01jan2020'd,0,0,0);
36 duration = dhms(1,2,3,4);
37 x = sum(dt,duration);
38 put (dt duration x) (=datetime22.) duration=time12.;
39 run;
dt=01JAN2020:00:00:00 duration=02JAN1960:02:03:04 x=02JAN2020:02:03:04 duration=26:03:04
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.