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

I have 4 variables that are formatted as time variables (hh:mm:ss). Specifically, I am looking to exclude any observations from the dataset where where the time interval is 00:00:00, negative, or greater than 01:00:00.

 

How would I write this code in a typical if/then delete data set?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
data want;
    set have;
    if time_interval<='00:00:00't or time_interval>'01:00:00't then delete;
run;

As a side issue, the variables are not "formatted as time variables", they are time variables, representing the number of seconds after midnight, or if you really have an interval, the value is the number of seconds in the interval. The format used is irrelevant to the above code, which will work however the variable TIME_INTERVAL is formatted and will work if the variable is not formatted.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
data want;
    set have;
    if time_interval<='00:00:00't or time_interval>'01:00:00't then delete;
run;

As a side issue, the variables are not "formatted as time variables", they are time variables, representing the number of seconds after midnight, or if you really have an interval, the value is the number of seconds in the interval. The format used is irrelevant to the above code, which will work however the variable TIME_INTERVAL is formatted and will work if the variable is not formatted.

--
Paige Miller
Kurt_Bremser
Super User

Which interval? Between values in separate observations for the same column, or between separate columns within a single observation?

 

Please supply some example data in a data step with datalines, and the expected outcome from that.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 806 views
  • 1 like
  • 3 in conversation