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!
Hi,
Your missing IN= option.
data cohort;
merge raw(in=in1) trmnt(in=in2);
by id;
if in1=1 and in2=0;
run;
Hi,
Your missing IN= option.
data cohort;
merge raw(in=in1) trmnt(in=in2);
by id;
if in1=1 and in2=0;
run;
Thank you so much! It worked 🙂
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.
It worked thanks!
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!
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.