BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ak2011
Fluorite | Level 6

Can somebody please help me with the right SAS code to model lung(Ca case) vs. cla_exp?

I was expecting pop cont to be zero(0) in the response profile in the output.

Also the class level information(0(non-substantial) and 1(substantial) for the output did not appear; this is an error .

I wish to model lung cancer case (“Ca case”)-dependent variable with cla_exp( independent variable), where 0=unexposed and 1=exposed to the pollutant.  I want to find the association between lung cancer (Ca case) and the pollutant cla _exp at substantial and Non-substantial levels using their estimates and Odds ratio(OR). My class variable is ‘level’.

My ultimate  aim is to find the estimates(OR) for the  number of Ca case and pop cont for “Unexposed vs. Exposed” , Substantial vs. Non-Substantial. Please find below code and log. Output attached.

Thanks.

ak.

 

 

/*Pollutants*/
data d1;
input id$ 1-5 job 7 id_job$ 9-15 hcl_exp 17 amo_exp 19 bio_exp 21 cla_exp 23;
datalines;
OSa03 4 OSa03_4 1 0 0 0
OSa06 3 OSa06_3 0 1 0 0
OSa13 1 OSa13_1 0 1 1 0
OSa13 3 OSa13_3 0 1 1 1
OSa29 2 OSa29_2 0 0 0 1
OSa29 4 OSa29_4 0 1 1 0
OSa30 4 OSa30_4 0 0 1 0
OSa30 1 OSa30_1 1 0 0 0
OSa30 2 OSa30_2 0 1 1 1
OSa54 3 OSa54_3 0 1 0 0
OSa64 3 OSa64_3 0 1 0 0
OSa73 3 OSa73_3 0 0 0 1
OSa74 3 OSa74_3 1 0 0 0
OSa78 3 OSa78_3 0 1 0 0
;
proc sort data=d1; by id; run;


/* Cancer subjects*/
data d2;
input id$ 1-5 lung$ 7-15;
datalines;
OSa01 Pop cont
OSa06 Ca cont
OSa11 Pop cont
OSa13 Ca case
OSa29 Ca cont
OSa30 Ca case
OSa31 Ca cont
OSa54 Pop cont
OSa73 Pop cont
;
proc sort data=d2; by id; run;


/* Exposure Duration*/
data d4;
input id$ 1-5 idchem 7-12 status$ 14-15 duration 16-18;
datalines;
OSa03 211701 S 6
OSa06 210701 S 9
OSa13 210701 S 37
OSa13 990005 S 5
OSa13 990021 S 37
OSa29 210701 NS 12
OSa29 990005 S 2
OSa30 210701 S 8
OSa30 211701 NS 8
OSa30 990005 S 8
OSa30 990021 S 15
OSa54 210701 NS 14
OSa64 210701 S 15
OSa74 211701 NS 21
OSa78 210701 NS 20
OSa78 990005 S 20
OSa78 990021 S 20
OSa86 990005 S 14
OSa93 210701 S 4
OSa93 990005 S 13
;

proc sort data=d4; by id; run;

Proc format;
value lung 0='Pop cont' 1='Ca case' 2='Ca cont';
value cla_exp 0='Unexposed' 1='Exposed';
value status 0='NS' 1='S';
run;


/* Merging d1 & d2*/
data mg124;
merge d1(in=a) d2(in=b) d4(in=c); by id;
if a and b and c;
if status eq "NS" then level="0";
if status eq "S" then level="1";
run;

proc print data=mg124;
title ' Table 1: Merged datasets d1, d2 and d4';
run;


proc logistic data=mg124;
class level(param=ref ref='0');
model lung(event='1') = cla_exp;
run;

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 /*Pollutants*/
74 data d1;
75 input id$ 1-5 job 7 id_job$ 9-15 hcl_exp 17 amo_exp 19 bio_exp 21 cla_exp 23;
76 datalines;
 
NOTE: The data set WORK.D1 has 14 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
91 ;
92 proc sort data=d1; by id; run;
 
NOTE: There were 14 observations read from the data set WORK.D1.
NOTE: The data set WORK.D1 has 14 observations and 7 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
93
94
95 /* Cancer subjects*/
96 data d2;
97 input id$ 1-5 lung$ 7-15;
98 datalines;
 
NOTE: The data set WORK.D2 has 9 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
108 ;
109 proc sort data=d2; by id; run;
 
NOTE: There were 9 observations read from the data set WORK.D2.
NOTE: The data set WORK.D2 has 9 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
 
 
110
111
112 /* Exposure Duration*/
113 data d4;
114 input id$ 1-5 idchem 7-12 status$ 14-15 duration 16-18;
115 datalines;
 
NOTE: The data set WORK.D4 has 20 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
136 ;
137
138 proc sort data=d4; by id; run;
 
NOTE: There were 20 observations read from the data set WORK.D4.
NOTE: The data set WORK.D4 has 20 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.02 seconds
 
 
139
140 Proc format;
141 value lung 0='Pop cont' 1='Ca case' 2='Ca cont';
NOTE: Format LUNG is already on the library WORK.FORMATS.
NOTE: Format LUNG has been output.
142 value cla_exp 0='Unexposed' 1='Exposed';
NOTE: Format CLA_EXP is already on the library WORK.FORMATS.
NOTE: Format CLA_EXP has been output.
143 value status 0='NS' 1='S';
NOTE: Format STATUS is already on the library WORK.FORMATS.
NOTE: Format STATUS has been output.
144 run;
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
 
 
145
146
147 /* Merging d1 & d2*/
148 data mg124;
149 merge d1(in=a) d2(in=b) d4(in=c); by id;
150 if a and b and c;
151 if status eq "NS" then level="0";
152 if status eq "S" then level="1";
153 run;
 
NOTE: MERGE statement has more than one data set with repeats of BY values.
NOTE: There were 14 observations read from the data set WORK.D1.
NOTE: There were 9 observations read from the data set WORK.D2.
NOTE: There were 20 observations read from the data set WORK.D4.
NOTE: The data set WORK.MG124 has 11 observations and 12 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
 
154
155 proc print data=mg124;
156 title ' Table 1: Merged datasets d1, d2 and d4';
157 run;
 
NOTE: There were 11 observations read from the data set WORK.MG124.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.26 seconds
cpu time 0.26 seconds
 
 
158
159
160 proc logistic data=mg124;
161 class level(param=ref ref='0');
162 model lung(event='1') = cla_exp;
163 run;
 
NOTE: Option EVENT= is ignored since LINK=CLOGIT.
NOTE: PROC LOGISTIC is fitting the cumulative logit model. The probabilities modeled are summed over the responses having the lower
Ordered Values in the Response Profile table. Use the response variable option DESCENDING if you want to reverse the
assignment of Ordered Values to the response levels.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 11 observations read from the data set WORK.MG124.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.50 seconds
cpu time 0.46 seconds
 
 
164
165 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
177

 


 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc logistic data=mg124;
class level(param=ref ref='0');
model lung(event='Pop Cont') = cla_exp level;
run;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc logistic data=mg124;
class level(param=ref ref='0');
model lung(event='Pop Cont') = cla_exp level;
run;
--
Paige Miller
ak2011
Fluorite | Level 6
Thank you.
ak.

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
  • 1004 views
  • 0 likes
  • 2 in conversation