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

Hi I have the following dataset

What I would like to do is to capture min two date time values, if missing use whichever one is available

IDfirst_stop_date_timesecond_stop_date_time
123401FEB20:21:56:0001FEB2020:13:15:00
456702FEB20:15:09:0003FEB2020:05:12:00
891021FEB20:00:00:00 

 

New dataset

IDfirst_stop_date_timesecond_stop_date_timemin_stop_date_time
123401FEB20:21:56:0001FEB2020:13:15:0001FEB2020:13:15:00
456702FEB20:15:09:0003FEB2020:05:12:0002FEB20:15:09:00
891021FEB20:00:00:00 21FEB20:00:00:00

 

The only way I can think of is transpose and combine into one date field and then use min. Was wondering if there is another easier way

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Isn't that just the MIN() function?

min_stop_date_time = MIN(first_stop_date_time, second_stop_date_time);

View solution in original post

1 REPLY 1
Reeza
Super User
Isn't that just the MIN() function?

min_stop_date_time = MIN(first_stop_date_time, second_stop_date_time);

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
  • 1 reply
  • 308 views
  • 0 likes
  • 2 in conversation