Hi All,
I hope this message finds you well. I am trying to the characteristics of the participants included and exclude. Here are my inclusion criteria. How could I get the dataset that I excluded? Thanks!
data elsa02;
set elsa01;
if age1<50 or age2<50 then delete;
if sight_persist=. then delete;
if hear_persist=. then delete;
if (cesd1>=0 or cesd2>=0);
if missing(cesd1) then cesd1=cesd2;
if missing(cesd2) then cesd2=cesd1;
if cesd3=. and cesd4=. and cesd5=. and cesd6=. and cesd7=. and cesd8=. and cesd9=. then delete;
if n(of cesd3-cesd9)<2 then delete;
if (cesd1>=3 or cesd2>=3) then delete;
run;
Haven't tried this, but for each DELETE, add en explicit output:
then do;
output excluded;
delete;
end;
Another option could be to join elsa01 with elsa02 using a NOT IN( ) condition.
I think your program can be rewritten as (not tested):
data elsa02 excluded;
set elsa01;
if age1<50 or age2<50 or
sight_persist=. or
hear_persist=. or
not (cesd1>=0 or cesd2>=0) or
n(of cesd3-cesd9)<2 or
(cesd1>=3 or cesd2>=3) then
output excluded;
else do;
if missing(cesd1) then cesd1=cesd2;
if missing(cesd2) then cesd2=cesd1;
output elsa02;
end;
run;
Explanation: I changed the subsetting IF to a condition preceded by NOT: "not (cesd1>=0 or cesd2>=0)"
The line
if cesd3=. and cesd4=. and cesd5=. and cesd6=. and cesd7=. and cesd8=. and cesd9=. then delete;
is not necessary, as it is covered by the "n(of cesd3-cesd9)<2" condition.
Combine your conditions into a single IF:
data
elsa02
excluded
;
set elsa01;
if
(cesd1 < 0 and cesd2 < 0)
or age1 < 50 or age2 < 50
or sight_persist = . or hear_persist = .
or n(of cesd3-cesd9) < 2
or cesd1 >= 3 or cesd2 >= 3
then output exclude;
else do;
if missing(cesd1) then cesd1 = cesd2;
if missing(cesd2) then cesd2 = cesd1;
output elsa02;
end;
run;
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.