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;

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 792 views
  • 0 likes
  • 3 in conversation