BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dataMart87
Quartz | Level 8

Hi, how do I create a flag, WANT, that checks if 1AM falls between two timestamps?

 

data task1;  
   input ID :$2. BEG_DT_TIME :datetime18. END_DT_TIME :datetime18. WANT;
   format BEG_DT_TIME END_DT_TIME datetime20.;
cards;
AA 28SEP2023:22:00:00.00 29SEP2023:02:00:00.00 1
BB 28SEP2023:07:30:00.00 28SEP2023:13:30:00.00 0
CC 28SEP2023:20:00:00.00 29SEP2023:00:00:00.00 0
DD 29SEP2023:00:00:00.00 29SEP2023:03:00:00.00 1
EE 29SEP2023:05:00:00.00 30SEP2023:03:00:00.00 1
	;
run;
1 ACCEPTED SOLUTION
4 REPLIES 4
andreas_lds
Jade | Level 19

Create an new timestamp using the datepart of end_dt_time to compare it with the start and end:

Want = (beg_dt_time <= dhms(datepart(end_dt_time), 1, 0, 0) <= end_dt_time);
dataMart87
Quartz | Level 8

Thanks, @Kurt_Bremser .  Curious what the .2 in hour24.2 does?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 660 views
  • 4 likes
  • 3 in conversation