Help using Base SAS procedures

Proc Logistic - Class statement

Reply
New Contributor Zoe
New Contributor
Posts: 2

Proc Logistic - Class statement

I am new to using the "class" statement in Proc Logistic. The output from Proc Logistic using the class statement does not order the Odds ratios in the order of the format or label. The data is looking at pack years of smoking and whether there is a dose response with pack years and cancer.

My format is

Value pkyrcat3f 1='never cig smk'

                  2='<20 pkyrs'

                  3='20-<40'

                  4='>=40';

The labels are

if packy =0 then  pkyrcat3= 1; else

if packy >0 and packy <20.00 then pkyrcat3=2; else

if packy >=20.00 and packy <40.00 then pkyrcat3=3;else

if packy >=40.00 then pkyrcat3=4;

Here is the Proc logistic call:

Note: when I used FIRST as the REF for PKYRCAT3, the referent was >=40 years, so I changed the referent to last

and the NEVER smoked category became the referent, which is the correct referent group.


proc logistic data=pan2.pkyr; /*1=case, 2= control*/

class age10yg(ref=first)sex race educat (ref=last) bmiad3cat (ref=first) etoh(ref=first)

diabetes(ref=last) pancreat(ref=last) pkyrcat3(ref=last) / param=ref;

model status= age10yg sex race educat bmiad3cat etoh diabetes pancreat hisp gb_stones pkyrcat3  /

selection = forward

include=11

ctable pprob= (0 to 1 by .1)

outroc=roc;

run;

quit;



From the output the automatically coded dummy variables are:

pkyrcat320-<40100
<20 pkyrs010
>=40001
never cig smk000


The correct order is as shown in the label. How can the correct order be obtained using the CLASS statement? Does the order NOT MATTER in the Odds Ratio result for looking at dose-response?  How can the variable be coded in the correct order using the CLASS statement versus creating manual dummy variables?  Thank you.

Regular Contributor
Posts: 217

Re: Proc Logistic - Class statement

Just a suggestion, maybe you could change your proc format like this so you don't need to do the if-else statement.

proc format;

Value pkyrcat3f 0='never cig smk'

                1-19 ='<20 pkyrs'

                20-39='20-<40'

                40-high='>=40';

proc logistic data=pan2.pkyr; /*1=case, 2= control*/

format packy pkyrcat3f.;

class age10yg(ref=first)sex race educat (ref=last) bmiad3cat (ref=first) etoh(ref=first)

diabetes(ref=last) pancreat(ref=last) packy (ref='never cig smk') / param=ref;

model status= age10yg sex race educat bmiad3cat etoh diabetes pancreat hisp gb_stones packy /

selection = forward

include=11

ctable pprob= (0 to 1 by .1)

outroc=roc;

run;

quit;

New Contributor Zoe
New Contributor
Posts: 2

Re: Proc Logistic - Class statement

Thanks, SO much,, Removing 'else' did not remove the coding problem. I think using 'packy' as the format might cause a problem because  'packy' is created earlier to differentiate smokers from non-smokers. see below...


/* never smoker =0 and ever smoker =1, must be sure that all variables are calculated based off TOEV because reflects recoding*/

if tobev = 1 then pkyr1=0;

if tobev = 2 then pkyr1=1;

if tobev = 3 then pkyr1=1;

This is used to add the current and former smokers cigarettes per day

if pkyr1=1 then do;

cigsum=sum(cpd, cpd_smkq); end;


Here is where 'packy' is created earlier in the program summing cigarettes and years smoked.

/*PACK YEARS VARIABLE– (cigs per day * yrs smoked) divided by 20 */

if pkyr1= 1 then packy=((cigsum * yrsum) / 20); else

packy=0;


So, is it OK to use 'packy' as the format? other suggestions?

Thanks, Cary

Super User
Posts: 17,907

Re: Proc Logistic - Class statement

The order doesn't matter for the odds ratio, because all are in comparison to the reference level.

If you want them displayed in a specific order, look at the order option on the class statement, the default is the FORMATTED and it sounds like you want the INTERNAL option instead.

proc logistic data=pan2.pkyr; /*1=case, 2= control*/

class age10yg(ref=first)sex race educat (ref=last) bmiad3cat (ref=first) etoh(ref=first)

diabetes(ref=last) pancreat(ref=last) pkyrcat3(ref=last) / param=ref ORDER=INTERNAL;

model status= age10yg sex race educat bmiad3cat etoh diabetes pancreat hisp gb_stones pkyrcat3  /

selection = forward

include=11

ctable pprob= (0 to 1 by .1)

outroc=roc;

run;

Relevant reference in the documentation:

SAS/STAT(R) 9.2 User's Guide, Second Edition

Ask a Question
Discussion stats
  • 3 replies
  • 230 views
  • 0 likes
  • 3 in conversation