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

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

7 REPLIES 7
Reeza
Super User

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. 


 

ballardw
Super User

@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.

michaelm90
Fluorite | Level 6

yes, sorry I am using the sas supplied data set sashelp.baseball

PaigeMiller
Diamond | Level 26

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...

 

Capture.PNG

--
Paige Miller
michaelm90
Fluorite | Level 6

still having trouble because division and league are not numerical variables 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Reeza
Super User

@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. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 779 views
  • 1 like
  • 4 in conversation