Hello,
I would appreciate if someone could help me with the SAS code to count the number of cases(ca case) and controls (pop cont) 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 would like the frequency to be split the frequence into ca case and pop cont. os3: pop cont, os6: ca case, o7: ca case and os9: ca case so in total there are 1 pop cont and 3 ca case (total 4 subjects) but I would like SAS to split the freq of 4 into their respective lung cancer type(ca case and pop cont). The output from attached table 2 is not correct. I need SAS to show and count only the unexposed subjects.
Please, can anyone help me to with the SAS code to solve this problem? My code and log are found below; results are attached, but actually Table 2 is incorrect.
Thank you.
ak.
data agents_exp;
input id$ a1 a2 a3 a4 lung$ 13-20;
datalines;
os1 1 0 0 1 ca case
os2 1 1 0 0 ca case
os3 0 0 0 0 pop cont
os5 1 0 0 1 pop cont
os6 0 0 0 0 ca case
os7 0 0 0 0 ca case
os8 1 0 1 1 pop cont
os9 0 0 0 0 ca case
;
run;
proc print data=agents_exp;
Title 'Table 1: Exposure of ids to 4 agents';
proc sql;
create table t as
select
id, a1, a2, a3,a4,lung,
sum(a1,a2,a3,a4)=0 as afinal
from agents_exp
;
quit;
proc freq data=t;
tables lung*afinal;
title 'Table 2: freq of ca case and pop cont for for unexposed agents';
run;
proc freq data=agents_exp(where=(sum(of a1-a4)=0)));
table lung;
run;
proc freq data=agents_exp(where=(sum(of a1-a4)=0)));
table lung;
run;
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!
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.