Hi, I am running a logistic regression model from an excel dataset, where each patient has multiple rows with information, so the Patient, Cancer, and Gender column are always the same, but the therapy column has different values. Like this example below:
Patient Cancer Gender Therapy
1 Y F 234
1 Y F 234
1 Y F 555
2 N M 444
2 N M 777
I'm trying to run a logistic regression where it doesn't count the multiple observations and only counts Patient 1 as 1 observation. It's been messing with my numbers and I'm not sure how to fix it.
This is how I usually code in proc logistic:
Proc logistic data=Data;
class Gender (ref="M") /param=ref;
model Disease (ref="N")= gender;
Run;
Thank you!!
Good Question. If you want more accuracy then pick PROC GLIMMIX, If you want handle big data then pick PROC GEE .
I've been looking up certain ways of doing this, and I found SAS pdf's that mentioned using Patient ID's as a repeated measure. Does anyone know how that would work with logistic regression?
Thank you!
to answer your first question, it would be wasteful to discard data but if there's some reason for using the first obs for each patient you can reduce the data set using "proc sort data=data nodupkey; by patient; run;"
you're right, however, with your second post, ie you likely want to use the repeated values for each patient. We would need to know more about the design of the study, eg the order the treatments were received, what exactly the outcome is etc. A cross over design is not uncommon and is maybe analogous. You can likely find SAS code examples online for a binary outcome. Note that you would not use proc logistic, in that case. Maybe you use proc nlmixed or genmod: https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_intromix_a0...
Thank you so much for responding to my thread. I've been playing around with Proc Glimmix, and it seems to be working fine, do you think this would be a better way of doing it over Proc Genmod?
PROC GLIMMIX DATA=Data;
CLASS ID Gender (ref= "M");
MODEL Disease (ref="N") = Gender /DIST=binary oddsratio;
RANDOM INTERCEPT /SUBJECT=ID TYPE=UN;
RUN;
but you don't have therapy in your model. Isn't that the most important thing? You seem to be interested in gender, but surely therapy is more likely to influence patient outcomes? It depends on why the study was designed, the objective and hypotheses etc. Personally, I'm not too familiar with glimmix, i used it many years ago when it was just a macro sas hadn't fully released. I would tend to use nlmixed. Glimmix v nlmixed is an interesting discussion tho : http://www2.sas.com/proceedings/forum2007/179-2007.pdf
How many therapies do you have? I feel like transposing the data and using dummy variables/one hot encoding makes sense as well here since none of the other data changes across rows?
It would become:
Patient Cancer Gender Therapy_234 Therapy_555 Therapy_444 Therapy_777
1 Y F 1 1 0 0
2 N M 0 0 1 1
This would also make sense if you have a baseline therapy you're comparing to.
Hi Reeza,
Thank you for responding, I'm not sure how I would do that. I am still pretty new to SAS. But I have 200 unique patients!
The number of patients doesn't matter (edit: to the question I asked), the number of therapies do.
Do you have the number of therapies?
You can use PROC TRANSPOSE to transpose your data and then create the 0/1's as necessary. The code is simple and we can help with that, but the methodology is more important first.
I have a total of 20 different therapies between 200 patients, thank you!
Ok, I don't think either way is going to matter, you have too many variables and too little observations - the general rule is 25-30 obs per variable. And since Therapy has 20 levels that'll be too complex. Not sure if the NLMIXED is appropriate. I'm going to move this to the stats forum so some people smarter than me can answer it 🙂
Thank you Reeza, I appreciate all the help!
1) PROC GEE 2) PROC GLIMMIX
Good Question. If you want more accuracy then pick PROC GLIMMIX, If you want handle big data then pick PROC GEE .
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.