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

Hello,

 

I am new to SAS, could you please help me how to generate exactly like in the below image results using proc logistic regression. I want to generate the odds ratio by categories in the variable and Confidence Intervals for the categories except the first category in the variables.  I am trying to predict a binary outcome and need the odds ratio table exactly like below. Please can someone help me with it. Below is the sample dataset.

 

Chapi_0-1606727524444.png

 

Target Education Health_insurance Living_arrangement Age Sex
0 -0.08264447 -0.677142541 0.979974336 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 1.055157965 -0.385145422 3.014553778 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 0.915907427 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 1.055157965 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 1.055157965 -0.385145422 3.014553778 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
1 -0.57348838 1.055157965 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
1 -0.08264447 1.055157965 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
1 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 1.055157965 -0.385145422 -0.607323603 0.9539654
0 -0.57348838 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 0.915907427 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 1.055157965 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 3.014553778 -1.04615533
1 -0.08264447 -0.677142541 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 1.055157965 -0.385145422 3.014553778 0.9539654
1 -0.08264447 1.055157965 -0.385145422 3.014553778 -1.04615533
1 -0.08264447 1.055157965 -0.385145422 0.915907427 0.9539654
1 -0.08264447 1.055157965 0.979974336 -0.607323603 0.9539654
0 -0.08264447 1.055157965 -0.385145422 3.014553778 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 1.055157965 0.979974336 0.915907427 -1.04615533
1 -0.08264447 -0.677142541 0.979974336 -0.607323603 -1.04615533
1 8.99941821 5.578245149 6.983458922 -0.607323603 0.9539654
1 -0.57348838 1.055157965 0.979974336 0.915907427 0.9539654
1 -0.08264447 -0.677142541 0.979974336 -0.607323603 0.9539654
0 -0.08264447 1.055157965 0.979974336 -0.607323603 0.9539654
1 -0.08264447 -0.677142541 -0.385145422 3.014553778 0.9539654
1 -0.08264447 1.055157965 0.979974336 -0.607323603 0.9539654
1 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 1.055157965 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 0.979974336 -0.607323603 0.9539654
1 -0.08264447 1.055157965 0.979974336 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 0.979974336 0.915907427 0.9539654
1 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 1.055157965 -0.385145422 3.014553778 -1.04615533
1 -0.08264447 1.055157965 0.979974336 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
1 -0.08264447 -0.677142541 0.979974336 -0.607323603 -1.04615533
0 -0.08264447 1.055157965 -0.385145422 0.915907427 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
1 -0.08264447 -0.677142541 -0.385145422 -0.607323603 0.9539654
0 -0.08264447 -0.677142541 -0.385145422 -0.607323603 -1.04615533
1 -0.57348838 -0.677142541 0.979974336 -0.607323603 -1.04615533
0 -0.08264447 -0.677142541 -0.385145422 0.915907427 0.9539654

 

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

If that is all the data you have, it is pretty sparse as evidenced by running this:

proc freq; 
table (Education	Health_insurance	Living_arrangement	Age	Sex)*Target; 
run;

Note the occurrences of only a single count in one of the predictor levels. So, you can filter those out cases and get results for the remaining data:

proc logistic ;
where education<8.99941821  and Health_insurance<5.578245149 and
Living_arrangement<6.983458922 and	Age<3.014553778;
class Target	Education	Health_insurance	Living_arrangement	Age	Sex;
model Target(event="1")=	Education	Health_insurance	Living_arrangement	Age	Sex;
run;

It's odd and unnecessary to have obviously categorical variables be numerically coded like this - I think you did some sort of thins with WOE, but that isn't needed. The above gives the odds ratios you want. You can always save them into a data set using an ODS OUTPUT statement if you want to do some other work with them.

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

@Chapi can you provide the data you're working with or some of it?

Chapi
Obsidian | Level 7
Hello,
Thank you. Attached the sample dataset.
StatDave
SAS Super FREQ

If that is all the data you have, it is pretty sparse as evidenced by running this:

proc freq; 
table (Education	Health_insurance	Living_arrangement	Age	Sex)*Target; 
run;

Note the occurrences of only a single count in one of the predictor levels. So, you can filter those out cases and get results for the remaining data:

proc logistic ;
where education<8.99941821  and Health_insurance<5.578245149 and
Living_arrangement<6.983458922 and	Age<3.014553778;
class Target	Education	Health_insurance	Living_arrangement	Age	Sex;
model Target(event="1")=	Education	Health_insurance	Living_arrangement	Age	Sex;
run;

It's odd and unnecessary to have obviously categorical variables be numerically coded like this - I think you did some sort of thins with WOE, but that isn't needed. The above gives the odds ratios you want. You can always save them into a data set using an ODS OUTPUT statement if you want to do some other work with them.

Chapi
Obsidian | Level 7
Thank you dave. It works perfect!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 721 views
  • 0 likes
  • 3 in conversation