Hello, this might be a really basic question, but I am struggling. Please help!
Report the p-value of comparing the average 1987 Salary in $ Thousands (SALARY) of four levels of League and Division (DIV). (up to four decimal places, please) using the sas supplied data set sashelp.baseball
I'm having trouble with this problem. I originally tried using proc ttest but since there are more than two levels I can't. I'm confused on how to use proc glm in this problem.
If they're not numeric variables, then you put them in the CLASS statement of PROC GLM and in the MODEL statement. @Reeza gave an example.
Use PROC ANOVA instead.
This would test if pain relief was related to the originating pain level which is a categorical variable with 8 levels.
title1 'Randomized Complete Block With Two Factors';
data PainRelief;
input PainLevel Codeine Acupuncture Relief @@;
datalines;
1 1 1 0.0 1 2 1 0.5 1 1 2 0.6 1 2 2 1.2
2 1 1 0.3 2 2 1 0.6 2 1 2 0.7 2 2 2 1.3
3 1 1 0.4 3 2 1 0.8 3 1 2 0.8 3 2 2 1.6
4 1 1 0.4 4 2 1 0.7 4 1 2 0.9 4 2 2 1.5
5 1 1 0.6 5 2 1 1.0 5 1 2 1.5 5 2 2 1.9
6 1 1 0.9 6 2 1 1.4 6 1 2 1.6 6 2 2 2.3
7 1 1 1.0 7 2 1 1.8 7 1 2 1.7 7 2 2 2.1
8 1 1 1.2 8 2 1 1.7 8 1 2 1.6 8 2 2 2.4
;
proc anova data=painrelief;
class painlevel codeine;
model relief = painlevel codeine;
run;quit;
@michaelm90 wrote:
Hello, this might be a really basic question, but I am struggling. Please help!
Report the p-value of comparing the average 1987 Salary in $ Thousands (SALARY) of four levels of League and Division (DIV). (up to four decimal places, please)
I'm having trouble with this problem. I originally tried using proc ttest but since there are more than two levels I can't. I'm confused on how to use proc glm in this problem.
@michaelm90 wrote:
Hello, this might be a really basic question, but I am struggling. Please help!
Report the p-value of comparing the average 1987 Salary in $ Thousands (SALARY) of four levels of League and Division (DIV). (up to four decimal places, please)
I'm having trouble with this problem. I originally tried using proc ttest but since there are more than two levels I can't. I'm confused on how to use proc glm in this problem.
If you are using the SAS supplied SASHELP.BASEBALL data set you should say so. Then we know what the data looks like.
yes, sorry I am using the sas supplied data set sashelp.baseball
In this case (but not in all cases), PROC ANOVA and PROC GLM give the same answers. Generally, I advise people to use PROC GLM and not PROC ANOVA because of the following warning at https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_an...
still having trouble because division and league are not numerical variables
If they're not numeric variables, then you put them in the CLASS statement of PROC GLM and in the MODEL statement. @Reeza gave an example.
@michaelm90 wrote:
still having trouble because division and league are not numerical variables
I modified my exmaple to include 2 categorical variables. Categorical variables do not need to be numeric.
Map your variables to mine - run the code to see the data first - and then replace the variable names as needed.
If it still doesn't work post your code and log. We can't see what you're doing otherwise or why it may be wrong.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.