I am trying to figure out the syntax to subset a dataset based on the date and time. First to grab all records that are prior to 12:01 a.m. Then within these records query another date variable for the date and time between 12:01 am and 4:00 am.
Assuming you have SAS dates/times and your variables are times it's fairly straightforward:
where timeVariable < '00:01:00't and timepart(secondDateTimeVariable) between '00:01:00't and '04:00;00't;
Key concepts:
@gstover wrote:
I am trying to figure out the syntax to subset a dataset based on the date and time. First to grab all records that are prior to 12:01 a.m. Then within these records query another date variable for the date and time between 12:01 am and 4:00 am.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.