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
- /
- calculating t-statistics

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

05-03-2012 04:10 AM

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

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

Posted in reply to rilatotoro

05-03-2012 12:31 PM

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.

All Replies

Solution

05-03-2012
12:31 PM

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

Posted in reply to rilatotoro

05-03-2012 12:31 PM

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.

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

Posted in reply to SAS_Bigot

05-03-2012 09:15 PM

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.

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

Posted in reply to rilatotoro

05-03-2012 09:44 PM

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