BookmarkSubscribeRSS Feed
yoyong
Obsidian | Level 7

Hi.

 

I want to do a paired test. I have a set of pre scores and two sets of post scores. 

 

For example:

 

Pre-exercise            Postexercise1       Postexercise2

12                                       21                       26

15                                       15                       16

18                                       18                       18

25                                       30                       28

25                                       25                       27                 

 

How do I do it in SAS without doing paired t-tests four times?

 

Thanks in advance.

 

 

2 REPLIES 2
PGStats
Opal | Level 21

You can do all comparisons in a single run of proc ttest

 

data have;
input Pre Post1 Post2;
datalines;
12                                       21                       26
15                                       15                       16
18                                       18                       18
25                                       30                       28
25                                       25                       27
;

proc ttest data=have;
paired Pre:Post1 Pre:Post2 Post1:Post2;
run;
PG
PGStats
Opal | Level 21

But if you want all tests to be based on the same error variance estimate, you can do

 

data have;
input Pre Post1 Post2;
datalines;
12                                       21                       26
15                                       15                       16
18                                       18                       18
25                                       30                       28
25                                       25                       27
;

data test;
set have;
length test $5;
subj + 1;
test = "Pre"; value = Pre; output;
test = "Post1"; value = Post1; output;
test = "Post2"; value = Post2; output;
keep subj test value; 
run;

proc glm data=test;
class subj test;
model value = subj test;
lsmeans test / pdiff;
run;
PG

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1014 views
  • 0 likes
  • 2 in conversation