BookmarkSubscribeRSS Feed
Saikiran_Mamidi
Obsidian | Level 7

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...

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26
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;
--
Paige Miller
novinosrin
Tourmaline | Level 20
data test;
 dt='01jan2020:00:00:00'dt;
 increment=1;
 dt=intnx('dtday',dt,increment)+'2:3:4't;
 format dt datetime20.;
run;
data_null__
Jade | Level 19

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

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 758 views
  • 7 likes
  • 4 in conversation