BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
I need to id a time of atferhours. here is my data test;;
Set test;
If starttime =>'19:00' t - '11:00' t and yes='yes' then atferhour='atferhour';

If endtime=>'01:00't -'06:00't and yes 'yes' then atferhour='atferhour';
Run;

It doesnt id correctly the time

The data looks
Starttime endtime. Atferhour
16:55. 17:29
14:41. 14:58
20:37. 20:43. Atferhour
23:52. 0:02. Atferhour
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why are you taking the difference between two constant times?  That doesn't make much sense.  

 

Are you trying to see if the variable is between the two constants?

Perhaps something like this?

'11:00't <= starttime <='19:00't 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Why are you taking the difference between two constant times?  That doesn't make much sense.  

 

Are you trying to see if the variable is between the two constants?

Perhaps something like this?

'11:00't <= starttime <='19:00't 
Jagadishkatam
Amethyst | Level 16

I am not clear with the query, but you can try the below code

 

data have;
input Starttime :time5. endtime :time5.;
if Starttime>='19:00't then afterhout='afterhour';
format Starttime endtime time5.;;
cards;
16:55 17:29
14:41 14:58
20:37 20:43 
23:52 0:02  
;
Thanks,
Jag

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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
  • 2 replies
  • 837 views
  • 0 likes
  • 3 in conversation