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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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