calculating t-statistics

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

calculating t-statistics

Hi I have 2 datafiles A and B with exactly the same variables price, size, weight.

Does anyone know how can i conduct a t-statistics to find out if the mean price/size/weight in A is different to the mean price/size/weight in B? Thanks.


Accepted Solutions
Solution
‎05-03-2012 12:31 PM
Frequent Contributor
Posts: 101

Re: calculating t-statistics

If the observations are independent of each other and are normally distributed then a simple proc ttest will suffice.

First, combine the 2 datasets into a single file. Create a variable named group to classify the source of the data.

data all;

set a (in=a)

     b;

if a then group = 'A';

else group = 'B';

run;

Then run proc ttest to compare the differences in means of price, size and weight.

proc ttest data=all plots(shownull)=interval;

class group;

var price size weight;

run;

Refer to the documentation for interpretation of the results. Basically, check the distribution and Q-Q plots to verify normality. Check to Equality of Variances to confirm the assumption of equal variances and determine the method for calculating the t value and confidence interval of the mean difference. Look at the confidence interval plot to see if the CI includes 0 (h0 = meanA-meanB=0). If so, then the means are not significantly different.

View solution in original post


All Replies
Solution
‎05-03-2012 12:31 PM
Frequent Contributor
Posts: 101

Re: calculating t-statistics

If the observations are independent of each other and are normally distributed then a simple proc ttest will suffice.

First, combine the 2 datasets into a single file. Create a variable named group to classify the source of the data.

data all;

set a (in=a)

     b;

if a then group = 'A';

else group = 'B';

run;

Then run proc ttest to compare the differences in means of price, size and weight.

proc ttest data=all plots(shownull)=interval;

class group;

var price size weight;

run;

Refer to the documentation for interpretation of the results. Basically, check the distribution and Q-Q plots to verify normality. Check to Equality of Variances to confirm the assumption of equal variances and determine the method for calculating the t value and confidence interval of the mean difference. Look at the confidence interval plot to see if the CI includes 0 (h0 = meanA-meanB=0). If so, then the means are not significantly different.

Occasional Contributor
Posts: 17

Re: calculating t-statistics

Hi thanks for your help. I did what you had written and found that that the distribution is not normal and the variances are not equal. Is there a way which I can do the Mann-Whitney U test on SAS or any other non parametric test? thank you.

Respected Advisor
Posts: 4,651

Re: calculating t-statistics

You can get exact non-parametric tests and confidence intervals for the difference between groups with:

data test;
set A B indsname=group;
run;

proc npar1way data=test;
class group;
var price size weight;
exact WILCOXON HL;
run;

PG

PG
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 502 views
  • 3 likes
  • 3 in conversation