Search code examples
statisticssaslinear-regression

How to write a code for multiple linear regression looking at predictors sex, age, weight for an outcome


I am very new to stats and have only taken one course so far (which did not cover this) so I am a little out of my wheelhouse. Thank you in advance for any help you can give.

I am working in SAS and am trying to figure out how to write a code where I can determine which, if any, of these predictors affect my outcome "value".

Details on my data: 4 groups basically, young female adults, senior female adults, young male adults, senior male adults. I have recorded a value for each group, but want to analyse this data continously rather than by group since each group ranges in age values. So far my data (and code that I have tried, and failed) looks something like this:

/*TestData*/
Data;
input Sex$ Age Value;
cards;
M   13  1
M   3   0.5
F   2   0.6
M   3   0.5
M   3   0.5
M   3   0.5
F   1   0.6
F   11  1.2
F   2   0.6
M   3   0.5
M   13  1
F   2   0.6
F   3   0.6
F   3   0.6
M   9   1
M   1   0.5
M   9   1
M   9   1
F   13  1.2
M   11  1
F   11  1.2
M   11  1
M   3   0.5
F   3   0.6
M   3   0.5
M   1   0.5
M   16  1
M   11  1
M   3   0.5
M   1   0.5
M   2   0.5
F   9   1.2
F   9   1.2
M   3   0.5
F   2   0.6
F   12  1.2
F   9   1.2


;
run;
proc reg;
model Value= Age Sex;
run;
proc reg;
model Value= Age;
run;
proc reg;
model Value= Sex;
run;
Proc reg;
model Value= Age Sex / selection= stepwise slentry=0.05;
run;
proc corr;
var Sex Age Value;
run;

I haven't even managed to put the weight predictor in there because I'm not sure how to add it. My code also does not like Sex being there.

I really just need to figure out if age, sex, or weight will affect my "value". Thank you in advance!


Solution

  • Of course, you have troubles with sex: it is a class variable, not a numeric one, so not suited for proc reg. What you need, is one of the Mixed Models

    Try this

    proc mixed;
      class sex;
      model Value = Age Sex;
    run;