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-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!

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
  • 614 views
  • 1 like
  • 3 in conversation