turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- ttest for difference in top and bottom quintiles

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 09:51 PM

Dear All,

I need to present **the difference** and the **t-test of difference** for the difference between the mean/median SIZE for the top & bottom quintiles. I first used proc ranks to create quintiles and then used proc means to obtained the means and median of size. I however don't know how to test the difference in the means and medians in SAS.

The program I used is as follows:

proc rank data=have group =5 ties=means out=want;

by year;

var size;

ranks quintiles;

run;

proc means data= want mean median;

var size;

by quintiles;

output out =final mean=msize median=medsize;

run;

The output I have is in the following format.

Quartile 0 | ||

Variable | Mean | Median |

msize | 0.065895 | 0.073575 |

medsize | 0.053472 | 0.039691 |

Quartile 1 | ||

Variable | Mean | Median |

msize | 0.082981 | 0.085829 |

medsize | 0.071721 | 0.088589 |

Quartile 2 | ||

Variable | Mean | Median |

msize | 0.056706 | 0.072663 |

medsize | 0.047843 | 0.072072 |

Quartile 3 | ||

Variable | Mean | Median |

msize | 0.097886 | 0.11662 |

medsize | 0.08756 | 0.098165 |

Quartile 4 | ||

Variable | Mean | Median |

msize | 0.100017 | 0.098385 |

medsize | 0.092094 | 0.090981 |

I need ttest to see if the difference in the mean and median of SIZE for top (quintile=0) and bottom (quintile=4)is significant. In other words, I want to see if 0.100 -0.065 (msize for quintile 4 - msize for quintile 0) is significant. Simialrly, 0.092-0053 (medsize for quintile 4 - medsize for quintile 0) is significant. I would appreciate if anyone could provide me with the formula for this test.

Accepted Solutions

Solution

11-17-2012
11:02 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 11:02 PM

Then, for the means, you want to do something like :

**proc glm data=want;**

**class quintiles;**

**model size = quintiles;**

**means quintiles / cldiff T;**

**run;**

PG

PG

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 10:17 PM

I'd be curious to know what is the purpose of these tests. Aren't quintiles ordered by SIZE, by definition? - PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 10:31 PM

The quintiles are ordered by salary not size. Sorry for the error.

Solution

11-17-2012
11:02 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 11:02 PM

Then, for the means, you want to do something like :

**proc glm data=want;**

**class quintiles;**

**model size = quintiles;**

**means quintiles / cldiff T;**

**run;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-17-2012 11:11 PM

And for the medians, something like :

**proc npar1way data=want(where=(quintiles in (0, 4))) median;**

**class quintiles;**

**var size;**

**run;**

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-20-2012 09:14 PM

Thanks PG for the codes.