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?
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).
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.
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;
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!
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.