BookmarkSubscribeRSS Feed
Guerraje
Quartz | Level 8

Hello, 

I am new to SAS am interesting in trying to run logistic regression. I want to adjust for Sex, Age, and Education while running the logistic regression with the factors listed on the table ( I am going to paste the table below to show the excel table I am trying to do the regression on). I would like to know if politics for example is significant with adjusting for sex, age and education. I will include how these variables are coded because I think that changes what statements we might be able to use. Thank you for any guidance in this. 

Screen Shot 2021-10-31 at 3.26.56 AM.png

-Our Sex variable is either (M) or (F)

- Our Education is binary 1 or 0 with this code

IF EDUCATION IN (4,5) THEN COLLEGE = 1;
ELSE IF EDUCATION IN (1,2,3) THEN COLLEGE = 0;
ELSE COLLEGE= . ;

- Our Age is coded in categories with this code:

proc format;
value agef 18-29= '18-29' 30-64='30-64'  65-high= '>65';
run;

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Show us the code you have tried so far.

--
Paige Miller
Guerraje
Quartz | Level 8
I am not sure where to start. I have never worked with logistic regression. When looking up possibilities, I have found proc logistic, or proc genmod, however, they both have certain specific uses which I am not sure meet, or do not meet criteria. I am not certain which statements are appropriate, and how to build the code for it.

Thank you
Guerraje
Quartz | Level 8

I am trying to use the code provided as an exmaple to follow from the links above where the examples are using titanice code.

 

what my code looks like is this 

 

PROC LOGISTIC DATA = vaccine_hesitancy descending;
where part=1;
class SEX AGE EDUCATION;
model VACCINEHESITANT(event= '1') = vaccinefactors1 vaccinefactors2 vaccinefactors3 vaccinefactors4 vaccinefactors5 vaccinefactors6 vaccinefactors7 vaccinefactors8 vaccinefactors9 vaccinefactors10 vaccinefactors11/
selection = stepwise expb stb lackfit ;
output out = temp p=new;
store vaccine_hesitancy_logistic;
run;

 

To begin, my error is " work.vaccine_hesitancy data" does not exist

Reeza
Super User
What exactly is your question for us though? I see the problem you're working on but not what you need help with.

FYI - Here are a few tutorials to get you started though. You do not need to dummy code your variables, SAS will do that and it will honour formats as well.

https://communities.sas.com/t5/SAS-Communities-Library/A-Guide-to-Logistic-Regression-in-SAS/ta-p/56...

https://documentation.sas.com/doc/en/statug/15.2/statug_logistic_examples02.htm
Guerraje
Quartz | Level 8
I am not sure where to start. I have never worked with logistic regression. When looking up possibilities, I have found proc logistic, or proc genmod, however they both have certain specific uses which I am not sure meet, or do not meet criteria. I am not certain which statements are appropriate, and how to build the code for it.

Thank you
Reeza
Super User
Do you have more specific questions after reviewing the links?
Guerraje
Quartz | Level 8

I am trying to use the code provided as an exmaple to follow from the links above where the examples are using titanice code.

 

what my code looks like is this 

 

PROC LOGISTIC DATA = vaccine_hesitancy descending;
where part=1;
class SEX AGE EDUCATION;
model VACCINEHESITANT(event= '1') = vaccinefactors1 vaccinefactors2 vaccinefactors3 vaccinefactors4 vaccinefactors5 vaccinefactors6 vaccinefactors7 vaccinefactors8 vaccinefactors9 vaccinefactors10 vaccinefactors11/
selection = stepwise expb stb lackfit ;
output out = temp p=new;
store vaccine_hesitancy_logistic;
run;

 

To begin, my error is " work.vaccine_hesitancy data" does not exist

Reeza
Super User
That means your input data set does not exist.
Confirm the data set does exist.
Guerraje
Quartz | Level 8

It is the dataset I have been using for my whole project. It seems like from the video it is the correct data I should be placing in that line. 

Reeza
Super User
So you made sure it's in the work library and you can see it?
If you run proc contents on that data set it works? Do you need to run earlier steps in the project to ensure it's created?

proc contents data=vaccine_hesitancy;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 1661 views
  • 2 likes
  • 3 in conversation