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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.