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

I'm quite new to SAS and did some in a dataset which I want to clean.
I have a dataset as shown below. The record shown is the one I want to delete from the dataset.

I want to get a program to clean my testing, but want it be based on date (datum), time (Tijd) and name (Mailing)

sas-example.png

I was thinking that below programcode would do the trick

DATA Datasettest2;
set Datasettest;
IF MAILING EQ 'ZM0000' AND Datum EQ "11jan2022"d AND Tijd EQ "16:49:24"T THEN DELETE;
RUN;

Unfortunately the program runs and the line is still there afterwards.

 

If I just search for date (datum) and name (Mailing) it works, but I want to be more specific with a timestamp added to preserve certain lines.

DATA Datasettest2;
set Datasettest;
IF MAILING EQ 'ZM0000' AND Datum EQ "11jan2022"d THEN DELETE;
RUN;

I am assuming there must me something with the time part as this doesn't work. 
I am specially looking for this time field to match, not to look for alternate solutions based on other fields.

I did a proc content and below is shown from the dataset. Maybe this could help?

sas-example3.png

sas-example2.png

sas-example5.png

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Obviously we don't have any of your data.

Equality is a pretty strong requirement. Depending on how your variable Tijd was created you might have a very small fractional second component that is not displayed with the TIME8. format, or is rounding to seconds. I suggest trying

 

round(Tijd) = "16:49:24"t

to force an integer number of seconds for comparison

View solution in original post

2 REPLIES 2
ballardw
Super User

Obviously we don't have any of your data.

Equality is a pretty strong requirement. Depending on how your variable Tijd was created you might have a very small fractional second component that is not displayed with the TIME8. format, or is rounding to seconds. I suggest trying

 

round(Tijd) = "16:49:24"t

to force an integer number of seconds for comparison

joostman2
Calcite | Level 5
Thank you!
Never thought beyond seconds.. Indeed rounding did the job
Thanks as well for the line, as I would not have known how to place that in the right order!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 595 views
  • 1 like
  • 2 in conversation