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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 997 views
  • 7 likes
  • 4 in conversation