Hello,
I would appreciate if someone could help me with the SAS code to count the number of subjects) not exposed to any of the the 4 agents (a1, a2,a3 and a4 ) below. Exposed is 1 and unexposed is zero (0). From the dataset, ids os3, os6, os7 and os9 are unexposed to any of the agents so the freq should be 4. I don't know if my approach is ok. In the results, I have controlling for a1=0 and a2=0. Does anyone has a better approach to this please? My code and log are found below; results are attached.
Thank you.
ak.
data agents_exp;
input id$ a1 a2 a3 a4;
datalines;
os1 1 0 0 1
os2 1 1 0 0
os3 0 0 0 0
os5 1 0 0 1
os6 0 0 0 0
os7 0 0 0 0
os8 1 0 1 1
os9 0 0 0 0
;
run;
proc print;
data a;
set agents_exp;
if a1 ne 0 then delete;
else if a2 ne 0 then delete;
else if a3 ne 0 then delete;
else if a4 ne 0 then delete;
run;
proc freq data=a;
tables a1*a2*a3*a4;
run;
@novinosrin wrote:
data agents_exp; input id$ a1 a2 a3 a4; datalines; os1 1 0 0 1 os2 1 1 0 0 os3 0 0 0 0 os5 1 0 0 1 os6 0 0 0 0 os7 0 0 0 0 os8 1 0 1 1 os9 0 0 0 0 ; run; proc print; proc sql; select count(*) from agents_exp where max(a1,a2,a3,a4)=0; quit;
@ak2011 did not show any missing results for the 4 values. If some missings were possible (unknown exposure perhaps) and you want known "not exposed" I would suggest including an N=4 in the condition.
data agents_exp;
input id$ a1 a2 a3 a4;
datalines;
os1 1 0 0 1
os2 1 1 0 0
os3 0 0 0 0
os5 1 0 0 1
os6 0 0 0 0
os7 0 0 0 0
os8 1 0 1 1
os9 0 0 0 0
;
run;
proc print;
proc sql;
select count(*)
from agents_exp
where max(a1,a2,a3,a4)=0;
quit;
@novinosrin wrote:
data agents_exp; input id$ a1 a2 a3 a4; datalines; os1 1 0 0 1 os2 1 1 0 0 os3 0 0 0 0 os5 1 0 0 1 os6 0 0 0 0 os7 0 0 0 0 os8 1 0 1 1 os9 0 0 0 0 ; run; proc print; proc sql; select count(*) from agents_exp where max(a1,a2,a3,a4)=0; quit;
@ak2011 did not show any missing results for the 4 values. If some missings were possible (unknown exposure perhaps) and you want known "not exposed" I would suggest including an N=4 in the condition.
Yes Sir @ballardw . Very good observation. I agree
We can also filter data at use with where clause like:
proc print data=agents_exp; where max(a1,a2,a3,a4) =0; run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.