BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
peppapig
Calcite | Level 5

Have:

START DATESTART TIMEEND DATEEND TIME
ID0112/7/201310:00:0012/8/201310:00:00
ID0212/7/20139:00:0012/8/20139:00:00

Want:three more new variables START, END, Time interval from START to END in seconds

START DATE

START TIME

START

END DATE

END TIME

END

Time Interval in Seconds

ID01

12/7/2013

10:00:00 AM

12/7/2013 10:00:00 AM    

12/8/2013

13:00:00 pm

12/8/2013 13:00:00 pm

??

ID02

12/7/2013

9:00:00 AM

12/7/2013 9:00:00 AM

12/8/2013

16:00:00 PM

12/8/2013 16:00:00 pm

??

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

start = dhms(start_date,Hour(start_time), Minute(start_time), Second(start_time));

end = dhms(end_date,Hour(end_time), Minute(end_time), Second(end_time));

interval = intck("SECOND", start, end);

PG

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

start = dhms(start_date,Hour(start_time), Minute(start_time), Second(start_time));

end = dhms(end_date,Hour(end_time), Minute(end_time), Second(end_time));

interval = intck("SECOND", start, end);

PG

PG
peppapig
Calcite | Level 5

Thanks!

This is so quick and awesome.

It's working!!!

data_null__
Jade | Level 19

I would skip all those extra functions as arguments to DHMS.

   s = dhms(sdate,0,0,stime);
   e = dhms(edate,0,0,etime);

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 456 views
  • 1 like
  • 3 in conversation