Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Proc TTEST To find if annualized salary is equal among ethnic groups

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-14-2019 11:05 AM
(753 views)

Hello,

I am trying to figure out a way to run t-tests on race to determine if there are any pay discrepancies. I have a code that runs now but I built it so i specify which race to compare, and create a data set for each of the possible combinations of races. Is there a more efficient way to accomplish this?

proc ttest data = mydata.client;

where group_n >=30 and race in ("A", "B");

class race;

by location job_group;

var annl_salary;

run;

What I am hoping to get is one data set that has each combination of race for each job location.

Job_group RACE1 RACE2 T-stat PVALUE DF

1c A B

1c A H

.

.

.

1c B H

1c B I

.

.

.

2a A B

...

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

This is a job for PROC GLM, which will do t-tests on all possible pairs (and also allows for multiple comparison adjustments so that if you are now comparing 15 different pairs, the p-values are adjusted appropriately, these are called Bonferroni t-tests, provided by the BON option).

```
proc glm data=mydata.client(where=(group_n>=30));
class race;
model annl_salary=race;
means race / t bon;
run;
quit;
```

--

Paige Miller

Paige Miller

11 REPLIES 11

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

This is a job for PROC GLM, which will do t-tests on all possible pairs (and also allows for multiple comparison adjustments so that if you are now comparing 15 different pairs, the p-values are adjusted appropriately, these are called Bonferroni t-tests, provided by the BON option).

```
proc glm data=mydata.client(where=(group_n>=30));
class race;
model annl_salary=race;
means race / t bon;
run;
quit;
```

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I think this is it (but didn't actually test it to see if it works):

```
ods output means=glmmeans;
proc glm ...;
...
run;
quit;
```

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

When I submit the below code:

ods output means = mydata.glmmeans;

proc glm data = mydata.christus(where =(group_n>=30));

class race;

model annl_salary = race;

means race / t bon;

run;

quit;

I get the error: "WARNING: Output 'means' was not created. Make sure that the output object name, label, or

path is spelled correctly. Also, verify that the appropriate procedure options are

used to produce the requested output object. For example, verify that the NOPRINT"

It seems that any output from proc glm is just the input data set with any additional measures added to the output statement. I apologize for all the questions, i am still fairly new at SAS.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@ggollehon_OD wrote:

When I submit the below code:

ods output means = mydata.glmmeans;

proc glm data = mydata.christus(where =(group_n>=30));

class race;

model annl_salary = race;

means race / t bon;

run;

quit;

I get the error: "WARNING: Output 'means' was not created. Make sure that the output object name, label, or

path is spelled correctly. Also, verify that the appropriate procedure options are

used to produce the requested output object. For example, verify that the NOPRINT"It seems that any output from proc glm is just the input data set with any additional measures added to the output statement. I apologize for all the questions, i am still fairly new at SAS.

When discussing errors or warnings it helps to include the entire procedure code and all messages related to that code copied from the log and pasted into a code box opened using the forums {I} to preserve the formatting of any error or warning messages.

Without the log we now ask questions like the following:

Did the Proc GLM run successfully? If the procedure errored out and did not run then the output would not be created.

What ODS destination do you have open? If none of the ods destinations are open the Means table would not be generated and would create this warning.

Were there any messages involving the MEANS statement? If this statement has an issue then the Means output table would not display and you would get this warning.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here is my output from the log file.

"742 ods output ttest = mydata.ttest;

743

744 proc glm data = mydata.client (where=(group_n>=30));

745 class race;

746 model annl_salary = race/ p ;

747 means race / t bon ;

748 run;

WARNING: ODS graphics with more than 5000 points have been suppressed. Use the

PLOTS(MAXPOINTS= ) option in the PROC GLM statement to change or override the cutoff.

749 quit;

WARNING: Output 'ttest' was not created. Make sure that the output object name, label, or

path is spelled correctly. Also, verify that the appropriate procedure options are

used to produce the requested output object. For example, verify that the NOPRINT

option is not used."

Both the t and bon tables are calculated, so the procedure ran correctly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here is my output from the log file.

"742 ods output ttest = mydata.ttest;

743

744 proc glm data = mydata.client (where=(group_n>=30));

745 class race;

746 model annl_salary = race/ p ;

747 means race / t bon ;

748 run;

WARNING: ODS graphics with more than 5000 points have been suppressed. Use the

PLOTS(MAXPOINTS= ) option in the PROC GLM statement to change or override the cutoff.

749 quit;

WARNING: Output 'ttest' was not created. Make sure that the output object name, label, or

path is spelled correctly. Also, verify that the appropriate procedure options are

used to produce the requested output object. For example, verify that the NOPRINT

option is not used."

Both the t and bon tables are calculated, so the procedure ran correctly.

I'm not quite sure what is meant when you say ODS destination?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

So, it would appear that GLM does not provide the t-values, but it does provide the confidence intervals. So you could compute the t-values from the confidence intervals and related information, using this formula: https://goo.gl/images/cjz12Q

```
ods output cldiffsinfo=cldiffsinfo cldiffs=cldiffs;
proc glm data = mydata.christus(where =(group_n>=30));
class race;
model annl_salary = race;
means race / t bon;
run;
quit;
```

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks. the issue still is getting the output saved. the resulting dataset either does not save, or does not have any of the figures from the output.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@ggollehon_OD wrote:

Thanks. the issue still is getting the output saved. the resulting dataset either does not save, or does not have any of the figures from the output.

Words like "doesn't save" doesn't help us understand what is wrong. Show us the code you are using and show us the SASLOG.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I see the problem now, it's my mistake 😞

` means race / t bon cldiff;`

--

Paige Miller

Paige Miller

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.