BookmarkSubscribeRSS Feed
ak2011
Fluorite | Level 6

 

Hello,

I would appreciate if someone could help me with the SAS code in logistic regression to find the estimate log odds/odds ratio of a comparison/reference group (refgroup) above. I have the same refgroup for the 2 agents(a1exp and a2exp).

I used a similar approach to the solution to my previous question that I posted on the forum and which was answered by someone. I am posting another question quite different from what I posted before.

Unexposed = 0, exposure levels: 1= high and 2=low.

Thanks in advance.

ak.

 

Main focus: Refgroup column; how to compute the ORs using logistic regression.

 

Reference group(refgroup) is composed of subjects (ids) not exposed to either of the agents(a1exp or a2exp). 2 ca cases (cases) and 6 pop cont(controls) met the criterion.

Please find below my code and log. Results are attached(Table 5: Exposure levels).

 

data expinfo;
input id$ 1-4 a1exp 6-7 a1exp_level$ 8-17 a1exp_cat 19-20
a2exp 26-27 a2exp_level$ 28-32 a2exp_cat 39-40 lung$ 48-55;
datalines;
os1 0 unexposed 0 1 high 1 ca case
os2 1 low 2 0 unexposed 0 ca case
os3 0 unexposed 0 0 unexposed 0 pop cont
os4 1 high 1 1 low 2 pop cont
os5 0 unexposed 0 0 unexposed 0 pop cont
os6 1 low 2 0 unexposed 0 ca case
os7 1 low 2 1 high 1 ca case
os8 0 unexposed 0 0 unexposed 0 ca case
os9 0 unexposed 0 0 unexposed 0 pop cont
os10 1 high 1 1 low 2 pop cont
os11 0 unexposed 0 0 unexposed 0 ca case
os12 1 low 2 0 unexposed 0 ca case
os13 1 high 1 1 low 2 ca case
os14 0 unexposed 0 0 unexposed 0 pop cont
os15 0 unexposed 0 0 unexposed 0 pop cont
os16 1 high 1 1 low 2 pop cont
os17 0 unexposed 0 1 high 1 pop cont
os18 0 unexposed 0 0 unexposed 0 pop cont
;
run;

/*proc print data=expinfo;

Title 'Table 1: Exposure of ids to 2 agents';*/

/*Step 1: Finding number of cases and controls unexposed to agents(a1,a2,a3 and a4)*/
proc freq data=expinfo(where=(sum(a1exp,a2exp)=0));
tables lung;
title 'Table 1:Subjects unexposed to either of the 2 agents';
run;



/*Step 2:Using subjects unexposed to any of agents as a ref. group*/

proc sql;
create table t as
select
id, a1exp, a2exp,lung,
sum(a1exp,a2exp)=0 as refgroup
from expinfo
;
quit;

proc print data=t;
title 'Table 2a: original variables and ref group';
run;

proc freq data=t;
tables lung* refgroup;
title 'Table 2b: freq of ca case and pop cont for ref group';
run;
proc freq data=expinfo;
tables lung* a1exp_level lung*a1exp_cat
lung* a2exp_level lung*a2exp_cat ;
title 'Table 3: freq of ca case and pop cont for vs lung';
run;

data logtest; set t;
if lung in ('ca case','pop cont');
run;

proc logistic data=logtest;
model lung(event='ca case') =refgroup;
Title 'Table 4: Estimates for ref. group';
run;

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data expinfo;
74 input id$ 1-4 a1exp 6-7 a1exp_level$ 8-17 a1exp_cat 19-20
75 a2exp 26-27 a2exp_level$ 28-32 a2exp_cat 39-40 lung$ 48-55;
76 datalines;
 
NOTE: The data set WORK.EXPINFO has 18 observations and 8 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
 
95 ;
96 run;
97
98 /*proc print data=expinfo;
99
100 Title 'Table 1: Exposure of ids to 2 agents';*/
101
102 /*Step 1: Finding number of cases and controls unexposed to agents(a1,a2,a3 and a4)*/
103 proc freq data=expinfo(where=(sum(a1exp,a2exp)=0));
104 tables lung;
105 title 'Table 1:Subjects unexposed to either of the 2 agents';
106 run;
 
NOTE: There were 8 observations read from the data set WORK.EXPINFO.
WHERE SUM(a1exp, a2exp)=0;
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.20 seconds
cpu time 0.20 seconds
 
 
107
108
109
110 /*Step 2:Using subjects unexposed to any of agents as a ref. group*/
111
112 proc sql;
113 create table t as
114 select
115 id, a1exp, a2exp,lung,
116 sum(a1exp,a2exp)=0 as refgroup
117 from expinfo
118 ;
NOTE: Table WORK.T created, with 18 rows and 5 columns.
 
119 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
120
121 proc print data=t;
122 title 'Table 2a: original variables and ref group';
123 run;
 
NOTE: There were 18 observations read from the data set WORK.T.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.22 seconds
cpu time 0.22 seconds
 
 
124
125 proc freq data=t;
126 tables lung* refgroup;
127 title 'Table 2b: freq of ca case and pop cont for ref group';
128 run;
 
NOTE: There were 18 observations read from the data set WORK.T.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.16 seconds
cpu time 0.15 seconds
 
 
129 proc freq data=expinfo;
130 tables lung* a1exp_level lung*a1exp_cat
131 lung* a2exp_level lung*a2exp_cat ;
132 title 'Table 3: freq of ca case and pop cont for vs lung';
133 run;
 
NOTE: There were 18 observations read from the data set WORK.EXPINFO.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.52 seconds
cpu time 0.52 seconds
 
 
134
135 data logtest; set t;
136 if lung in ('ca case','pop cont');
137 run;
 
NOTE: There were 18 observations read from the data set WORK.T.
NOTE: The data set WORK.LOGTEST has 18 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
 
138
139 proc logistic data=logtest;
140 model lung(event='ca case') =refgroup;
141 Title 'Table 4: Estimates for ref. group';
142 run;
 
NOTE: PROC LOGISTIC is modeling the probability that lung='ca case'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 18 observations read from the data set WORK.LOGTEST.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.44 seconds
cpu time 0.40 seconds
 
 
143
144
145 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
157

 

 

2 REPLIES 2
Ksharp
Super User

Better post it at Stat Forum. @StatDave  @Rick_SAS   could give you a hand.

Rick_SAS
SAS Super FREQ

I think the OP cross-posted this message. This entry in the Statistical Community looks the same:

https://communities.sas.com/t5/Statistical-Procedures/Creating-a-reference-group-from-unexposed-subj...

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 481 views
  • 0 likes
  • 3 in conversation