BookmarkSubscribeRSS Feed
MisterJenn
Fluorite | Level 6

Not sure how to write this code. I am trying to answer this question: 

  • Remove from the data set any observations where the date of delivery was recorded as before the date of admission to the hospital or after the date of discharge from the hospital.

When I use this code it says I have no observations:

date2 = date of delivery 

date1 = date of admission to the hospital 

dod = date of discharge

data dil_merge;
merge hw6.dil1 hw6.dil2_temp; 
by MEDRNO;
if xwtgainlb > 60 then delete; 
if xwtgainlb < 60 then delete; 
if date2 < date1 then delete; 
if date2 > dod then delete; 
run; 

 

3 REPLIES 3
tarheel13
Rhodochrosite | Level 12

can you post your data?

fja
Lapis Lazuli | Level 10 fja
Lapis Lazuli | Level 10

Hello!

A quick question: Does the code without the last to if clauses meet your expectations?

i.e. does the code:

data dil_merge;
merge hw6.dil1 hw6.dil2_temp; 
by MEDRNO;
if xwtgainlb > 60 then delete; 
if xwtgainlb < 60 then delete; 
run; 

return the correct results. 

If yes, then you needed to check on xwtgainlb as @Kurt_Bremser has already suggested.

--fja

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
  • 3 replies
  • 517 views
  • 1 like
  • 4 in conversation