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.
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;
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;
Could you tell me what I am supposed to put in place of 'have'.
data RegData;
set have..........NOT CLEAR;
PCP=(PCP>0);
run;
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.