## TTEST and difference of two sample means

Solved
Occasional Contributor
Posts: 5

# TTEST and difference of two sample means

I have attached a data set that I am working on. Basically, i ned to run a 95% confidence interval for the difference in population mean hours of sleep for students who are sleep deprived and who are not. My issue is, I have no idea how to do this, and every example i see for TTEST and confidence interval involves data that people are entering themselves and each variable only has one item.

Here is my issue, the below is exactly what is the format of the excell sheet. I need to do the individual means of the yes and no seperately, and then find the difference between the two sample means. after that, i need to construct a 95% confidence interval for the difference in population mean hours of sleep for studetns who would say they are (yes), and the studetns who said they were not (no). Every example i see only has numbers for var1, but i need to actually do it for subgroups within the var 1. I do not know how to do this.

Var1     var 2

yes         2

no           3

yes         6

no         7

yes         9

no          10

yes         .

no            .

yes

no

yes

no

.

.

.

.

.

Accepted Solutions
Solution
‎06-20-2016 01:40 PM
Super User
Posts: 23,700

## Re: TTEST and difference of two sample means

Two sample T-Tests - You would have to download the sample dataset to see the data structure but it matches your data.

http://www.ats.ucla.edu/stat/sas/whatstat/whatstat.htm

http://www.ats.ucla.edu/stat/sas/output/ttest.htm

And another way, if you precalculate statistics:

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_ttest_exampl...

All Replies
Super User
Posts: 13,521

## Re: TTEST and difference of two sample means

For a ttest on your data you would use:

proc ttest data=have;

class var1;

var var2;

run;

The CLASS variable is one that designates membership in a group, sleep deprived in your case. The VAR variable(s) are ones you want to conduct the test for similar means.

Solution
‎06-20-2016 01:40 PM
Super User
Posts: 23,700

## Re: TTEST and difference of two sample means

Two sample T-Tests - You would have to download the sample dataset to see the data structure but it matches your data.

http://www.ats.ucla.edu/stat/sas/whatstat/whatstat.htm

http://www.ats.ucla.edu/stat/sas/output/ttest.htm

And another way, if you precalculate statistics:

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_ttest_exampl...

🔒 This topic is solved and locked.