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

Hi,

 

How do I subset data based on a time variable? The variable has the time format which makes it look like "21:36:00." I want anyone between 7pm and 12pm?

 

Num8TIME.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

use time constant

 

where time_variable between '7:00pm't and '12:00pm't;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

use time constant

 

where time_variable between '7:00pm't and '12:00pm't;

lalaktgrau
Fluorite | Level 6

Do you know if there is a way to combine a date variable and a time variable to create a Datetime variable?

Kurt_Bremser
Super User

@lalaktgrau wrote:

Do you know if there is a way to combine a date variable and a time variable to create a Datetime variable?


The dhms() function. Use the date as the first and the time as the fourth parameter; set the second and third parameter to zero.

Kurt_Bremser
Super User

12 pm is (per definition) noon, so your rule would include everything from 19:00 on one day to 12:00 on the next.

I rather guess you want to include everything between '19:00:00't and '24:00:00't;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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