BookmarkSubscribeRSS Feed
zihdonv19
Quartz | Level 8

My data is like:

data have;
   input group_num 	id cc	years_on_drug category_drug$ weight education$;

datalines;
1 	1 	1 3  A 55 high
1 	2 	0 6  B 56 low
1 	3 	0 8  C 45 mid
2 	4 	1 12 C 78 mid
2 	5 	0 2  C 88 mid
2 	6 	0 1  A 54 mid
3   7   1 3  B 66 low
3   8   0 2  A 64 high
3   9   0 16 C 65 high
4   10  1 9  A 70 mid
4   11  0 7  A 78 low
4   12  0 4  B 79 mid
5   13  1 5  B 80 high
5   14  0 2  C 64 low"
5   15  0 1  C 83 low"
;
run;

 

I have R code below to run a conditional logistic regression model with categorical*continuous interaction term:

 

model = clogit ( cc ~years_on_drug:category_drug +
education + weight+
strata (group_num), data=have)
model

 

I want to use SAS to get the same output as in R (odds ratios rather than coefficients), could anyone help with this?

 

4 REPLIES 4
ballardw
Super User

Don't speak R much so this is sort of a generic Logistic translation with your variables.

 

proc logistic data=have;
   class category_drug education ;
/*   strata group_num;*/
   model   years_on_drug=category_drug weight education 
     / link= clogit ;
   oddsratio category_drug ;
   oddsratio weight;
   oddsratio education;
run;

I have commented out STRATA because your example data is so small that didn't get the odds because there weren't any within strata. I'm not sure at all how R uses strata so it may be that BY Group_num; is more appropriate.

 

SAS defaults to reference levels for classification level. So if you want things expressed in relation to specific level of a class variable then you add a (ref='Level value') on the class statement for that variable. Default will be Last, meaning the last value in the order of the variable (normally).

StatDave
SAS Super FREQ

Your response variable is not binary. The conditional logistic model is only available (via the STRATA statement in PROC LOGISTIC) when the response is binary. Since it is a number of years, it might be more appropriate to fit a GEE model using a distribution like Poisson, negative binomial, or gamma using a log link. You can do that in PROC GEE using the REPEATED statement.

zihdonv19
Quartz | Level 8
thanks for your reply. maybe I didn't explain clearly about my variables. actually my outcome variable is "cc". The years of drug, category of drug, education and weight are predictors. Besides, I also want to add the interaction term between years of drug use and category of drug as predictors in my model. Do you know whether it's possible to get odds ratio directly in SAS in this situation?
StatDave
SAS Super FREQ

OK... I see now. The code below attempts to fit your conditional model, but with such little data, it doesn't converge properly. If the interaction is removed, it fits but some standard errors are huge indicating continuing convergence problems. Further simplification of the model should allow for proper convergence.

proc logistic data=have;
   class category_drug education;
   strata group_num;
   model cc=years_on_drug|category_drug weight education;
oddsratio years_on_drug; oddsratio category_drug; oddsratio weight; oddsratio education; run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 786 views
  • 1 like
  • 3 in conversation