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
- /
- Analytics
- /
- Stat Procs
- /
- paired t-test

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-30-2014 01:44 PM

I am trying to program the given information for a paired t-test. How would I go about doing this using an array? The information I am trying to read in is:

DATA exam;

input id $ s1-4;

DATALINES;

Start 30 15 20 45

End 35 16 25 42

;

RUN:

below is the general information - we have 4 subjects with a starting grade and an ending grade. I would like to perform a paired t-test.

Subject 1 2 3 4

Start 30 15 20 45

End 35 16 25 12

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

Posted in reply to Bailey

07-30-2014 01:57 PM

Sample size is too small to draw any conclusions from this data.

The data is not in the correct format for a SAS test, it would have to be formatted differently. If you have only the four obs that's easy enough to change though:

data paired_example;

input subject start end @@;

datalines;

1 30 35 2 15 16 3 20 25 4 45 12

;

run;

proc ttest data=paired_example;

paired end*start;

run;

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

Posted in reply to Bailey

07-30-2014 02:19 PM

I understand that it is a small sample size (I am just using a small sample size b/c I did not want to input the large sample size I truly have). I know it would be easy to complete this just changing the input and datalines, but I do not want to do that. I really want to read in the original datalines (exactly as it is) and use an array so I can eventually use proc ttest. How would I read in the original data and use an array so I can eventually use proc ttest?

DATA exam;

input id $ s1-4;

DATALINES;

Start 30 15 20 45

End 35 16 25 42

;

RUN:

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

Posted in reply to Bailey

07-30-2014 03:03 PM

You can't use an array with the t-test unless you want to manually calculate the t-test. You will have to transform your data, to the type that the proc expects it and you can do that via proc transpose. You had some typos in your sample data which are corrected below.

DATA exam;

input id $ s1-s4;

DATALINES;

Start 30 15 20 45

End 35 16 25 42

;

RUN;

proc transpose data=exam out=paired_example;

id id;

run;

proc ttest data=paired_example;

paired end*start;

run;

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

Posted in reply to Bailey

07-30-2014 02:42 PM

data want(keep=id s);

set exam;

array st{*} s1-s4;

do i=1 to dim(st);

s=st{i};

output;

end;

run;

proc ttest data=want;

class id;

var s;

run;

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

Posted in reply to Bailey

07-30-2014 02:57 PM

But that would not allow me to use a paired t-test.

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

Posted in reply to Bailey

07-31-2014 09:52 AM

and also you can use dif=End-Start to eliminate their correlation , then use proc ttest H0 : dif=0

Xia Keshan

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

Posted in reply to Ksharp

07-31-2014 11:19 AM

Except s/he has the items in different rows so not quite, would still need a transpose.

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

Posted in reply to Reeza

08-01-2014 09:08 AM

Yes. the data should be transposed firstly.