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

Hi,

 

I have two datasets (raw and trmnt) and I am trying to remove some observations in Dataset A (raw data) based on Dataset B (trmnt, containing IDs of those who need to be removed from Dataset A), because individuals have an unknown treatment status. 

 

I merged the datasets A and B together by using the following code:

data cohort;

merge raw trmnt;

by id;

if raw and not trmnt;

run;

 

Then when I run the code, it yields 0 observations and a note stating raw and trmnt are uninitialized... but in the previous line of code SAS read the individual observations from each of the datasets. Any insight on why this could be? Thanks!

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

Hi,

 

Your missing IN= option.

 

data cohort;
merge raw(in=in1) trmnt(in=in2);
by id;
if in1=1 and in2=0;
run;
Thanks,
Suryakiran

View solution in original post

5 REPLIES 5
SuryaKiran
Meteorite | Level 14

Hi,

 

Your missing IN= option.

 

data cohort;
merge raw(in=in1) trmnt(in=in2);
by id;
if in1=1 and in2=0;
run;
Thanks,
Suryakiran
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS communities 🙂 I think what you try to do is this

 

data cohort;
   merge raw(in=a) trmnt(in=b);
   by id;
   if a and not b;
run;

Let us know if it works. If it does not, please provide some example data for us to test and work with.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 966 views
  • 0 likes
  • 4 in conversation