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

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Good Question.
If you want more accuracy then pick PROC GLIMMIX,
If you want handle big data then pick PROC GEE .



View solution in original post

13 REPLIES 13
kmardinian
Quartz | Level 8

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!

pau13rown
Lapis Lazuli | Level 10

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...

kmardinian
Quartz | Level 8

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;

 

 

pau13rown
Lapis Lazuli | Level 10

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

Reeza
Super User

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. 

 

kmardinian
Quartz | Level 8

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!

Reeza
Super User

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.

 

 

kmardinian
Quartz | Level 8

I have a total of 20 different therapies between 200 patients, thank you!

Reeza
Super User

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 🙂

kmardinian
Quartz | Level 8

Thank you Reeza, I appreciate all the help!

Ksharp
Super User
1) PROC GEE
2) PROC GLIMMIX


kmardinian
Quartz | Level 8
Thank you so much for responding. Is there a reason I would use proc
glimmix instead of proc genmod?
Ksharp
Super User
Good Question.
If you want more accuracy then pick PROC GLIMMIX,
If you want handle big data then pick PROC GEE .



sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 13 replies
  • 1944 views
  • 0 likes
  • 4 in conversation