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