ttest for difference in top and bottom quintiles

Solved
Frequent Contributor
Posts: 96

ttest for difference in top and bottom quintiles

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
Posts: 5,540

Re: ttest for difference in top and bottom quintiles

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
Posts: 5,540

Re: ttest for difference in top and bottom quintiles

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

PG
Frequent Contributor
Posts: 96

Re: ttest for difference in top and bottom quintiles

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

Solution
‎11-17-2012 11:02 PM
Posts: 5,540

Re: ttest for difference in top and bottom quintiles

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
Posts: 5,540

Re: ttest for difference in top and bottom quintiles

And for the medians, something like :

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

class quintiles;

var size;

run;

PG

PG
Frequent Contributor
Posts: 96

Re: ttest for difference in top and bottom quintiles

Thanks PG for the codes.

🔒 This topic is solved and locked.