ttest for difference in top and bottom quintiles

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 96
Accepted Solution

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
VariableMeanMedian
msize0.0658950.073575
medsize0.0534720.039691
Quartile 1
VariableMeanMedian
msize0.0829810.085829
medsize0.0717210.088589
Quartile 2
VariableMeanMedian
msize0.0567060.072663
medsize0.0478430.072072
Quartile 3
VariableMeanMedian
msize0.0978860.11662
medsize0.087560.098165
Quartile 4
VariableMeanMedian
msize0.1000170.098385
medsize0.0920940.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
Respected Advisor
Posts: 4,927

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

View solution in original post


All Replies
Respected Advisor
Posts: 4,927

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
Respected Advisor
Posts: 4,927

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
Respected Advisor
Posts: 4,927

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.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 542 views
  • 3 likes
  • 2 in conversation