BookmarkSubscribeRSS Feed
kplbug8
Calcite | Level 5

Hello, this question may be relatively simple, I am just starting to learn all this so thank you in advance.

 

To simplify my data, let's say I have 1 outcome in 37 subjects. Those subjects were technically allocated to two age groups (young adult and senior), but I also want to analyse the results continuously instead of grouped by age. They were also of both sexes so I want to see if that also has an effect on the outcome. My data, for example, can look something like this (I have changed the outcome values for testing purposes):

 

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

I have other predictors I'd like to look into as well such as weight, date sample was collected, and so on, but am not sure if I can just add them here?

 

 

How would I go about testing to see if age and sex have an impact on the Value? So far I have tried this (inserted below), but it does not like the sex variable. Also, could I include other predictors into this same code without having to run another one?

/*Test Data*/
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 have taken one stats course so far and this was not included, so I am a bit out of my wheelhouse on this!

 

Thank you so much in advance,

1 REPLY 1
Reeza
Super User

Sex is a categorical predictor and REG does not handle character variables. You will need to either manually dummy code that variable or use a different proc (recommended). In that case I would recommend PROC GLM.

 

I would highly, highly recommend giving your data set names. Makes it much easier to trace your code as it gets longer.

 

 

proc glm data=responses;
class sex;
model value =  age sex;
run;

proc glm data=responses;
model value= age;
run;

proc glm data=responses;
class sex;
model value = sex;
run;

proc corr data=responses;
var age value;
run;

proc sort data=responses;
by sex;
run;

proc corr data=responses;
by sex;
var age value;
run;

Note the SAS Stats training course is free.

 

Spoiler

@kplbug8 wrote:

Hello, this question may be relatively simple, I am just starting to learn all this so thank you in advance.

 

To simplify my data, let's say I have 1 outcome in 37 subjects. Those subjects were technically allocated to two age groups (young adult and senior), but I also want to analyse the results continuously instead of grouped by age. They were also of both sexes so I want to see if that also has an effect on the outcome. My data, for example, can look something like this (I have changed the outcome values for testing purposes):

 

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

I have other predictors I'd like to look into as well such as weight, date sample was collected, and so on, but am not sure if I can just add them here?

 

 

How would I go about testing to see if age and sex have an impact on the Value? So far I have tried this (inserted below), but it does not like the sex variable. Also, could I include other predictors into this same code without having to run another one?

/*Test Data*/
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 have taken one stats course so far and this was not included, so I am a bit out of my wheelhouse on this!

 

Thank you so much in advance,


SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 341 views
  • 1 like
  • 2 in conversation