Programming the statistical procedures from SAS

How do you run a two sample t test?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

How do you run a two sample t test?

I'm a new user to SAS, and I am trying to figure out how to run a two sample t-test by referencing data I had previously imported from two different excel files. I am using the most recent version of SAS studio (I installed SAS on my Virtual Box two weeks ago). When importing my excel files, I used this code: 

 

PROC IMPORT OUT= WORK.auto
DATAFILE= "/folders/myfolders/auto.xls"
DBMS=XLS REPLACE;
GETNAMES=YES;
RUN;

 

I am aware that you can run two sample t-tests by using this kind of code:

 

DATA response;

   INPUT group $ time;

DATALINES;

c 80

c 93

c 83

c 89

c 98

t 100

t 103

t 104

t 99

t 102

;

PROC UNIVARIATE DATA = response normal plot;

   class group;

   var time;

   histogram time / midpoints = 80 to 120 by 5 normal;

RUN;

 

However, I am running t-tests on data sets with 1000+ entries, and I was wondering, is there any way that I can reference data in a column on the table I pulled in from the first block of code? Like, instead of copying and pasting in the data set from a column, is there some line of code I can use to just reference a certain column from the data? I would really appreciate it if you can post a sample code that would be able to do this. 

 

Also, is there some manual on SAS that would teach me how to run code on t-tests, Z-scores, chi squares, etc?

 

Thanks!


Accepted Solutions
Solution
‎07-25-2016 02:37 PM
SAS Employee
Posts: 106

Re: How do you run a two sample t test?

Hi. There's a pretty good chance I'm just not following, but maybe this will help: 

 

1. For a t-test of two independent samples, use proc ttest. 

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_ttest_a0000...

 

2. Once you've imported your data, no pasting of data should necessary.  If your IMPORT creates work.auto, then reference that datast on your subsequent proc ttest call, e.g.,:

 

proc import out=auto....;

....

...

run; 

proc ttest data = auto....;

...

....

run; 

 

 

View solution in original post


All Replies
Solution
‎07-25-2016 02:37 PM
SAS Employee
Posts: 106

Re: How do you run a two sample t test?

Hi. There's a pretty good chance I'm just not following, but maybe this will help: 

 

1. For a t-test of two independent samples, use proc ttest. 

 

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_ttest_a0000...

 

2. Once you've imported your data, no pasting of data should necessary.  If your IMPORT creates work.auto, then reference that datast on your subsequent proc ttest call, e.g.,:

 

proc import out=auto....;

....

...

run; 

proc ttest data = auto....;

...

....

run; 

 

 

Occasional Contributor
Posts: 9

Re: How do you run a two sample t test?

I'll try that out and see if it works!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 237 views
  • 1 like
  • 2 in conversation