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

   Hello everyone,

Can anyone suggest me a code for logistic regression

 

Question: Perform a logistic regression with covariates age/sex/race on the outcome of having at least 1 visit to a Primary Care Provider. (PCP = Primary Care Provider)

 

ID    PCP SEX RACE AGE

 1   8    1    1    71
  2  8    1    1    65
 3   8    2    1    81
 4   8    1    1    75
 5   8    2    1    83
 6   8    2    1    79
 7   8    1    1    66
 8   8    2    1    71
 9   8    1    1    86
 10   8    2    1    70
  11  8    2    1    76
  12  8    1    1    75
 13   8    2    1    66
  14  8    2    1    91
 15   8    2    1    67
    Any help will be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

The first thing you need to do is to get your data in a form that suits the question. If you want to model the outcome of having at least 1 visit to a Primary Care Provider, then PCP should be a binary variable, created like below. The example code for the logistic regression can then easily be found in the Examples Section of the PROC LOGISTIC Documentation

 

data have;
input ID PCP SEX RACE AGE;
datalines;
1 8 1 1 71
2 8 1 1 65
3 8 2 1 81
4 8 1 1 75
5 8 2 1 83
6 8 2 1 79
7 8 1 1 66
8 8 2 1 71
9 8 1 1 86
10 8 2 1 70
11 8 2 1 76
12 8 1 1 75
13 8 2 1 66
14 8 2 1 91
15 8 2 1 67
;

data RegData;
   set have;
   PCP=(PCP>0);
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

The first thing you need to do is to get your data in a form that suits the question. If you want to model the outcome of having at least 1 visit to a Primary Care Provider, then PCP should be a binary variable, created like below. The example code for the logistic regression can then easily be found in the Examples Section of the PROC LOGISTIC Documentation

 

data have;
input ID PCP SEX RACE AGE;
datalines;
1 8 1 1 71
2 8 1 1 65
3 8 2 1 81
4 8 1 1 75
5 8 2 1 83
6 8 2 1 79
7 8 1 1 66
8 8 2 1 71
9 8 1 1 86
10 8 2 1 70
11 8 2 1 76
12 8 1 1 75
13 8 2 1 66
14 8 2 1 91
15 8 2 1 67
;

data RegData;
   set have;
   PCP=(PCP>0);
run;
prjadhav00
Calcite | Level 5
Thanks for the suggestion
prjadhav00
Calcite | Level 5

Could you tell me what I am supposed to put  in place of 'have'.

data RegData;
   set have..........NOT CLEAR;
   PCP=(PCP>0);
run;

 

Reeza
Super User
SET is telling SAS what your input data set is, so what's your input data set.
PaigeMiller
Diamond | Level 26

If I am understanding your problem properly, this data doesn't seem to match the problem description, nor does the addition by @PeterClemmensen. You would be doing a logistic regression where the responses are 1 for every observation, which doesn't work in logistic regression. You would need some zeros in the Y variable to fit a logistic regression.

--
Paige Miller
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1621 views
  • 0 likes
  • 4 in conversation