BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xinyao
Fluorite | Level 6

I have data  like below:

2 group

30 measure

 

 site      measure  group   c1 

1            1                1        67   

 1           1                1        74   

1              2                 1       44  

1            2                 1     32  

         3                 1      124   

1            3                1     137  

1            4                 1      58  

1             4                1   55  

…………….

22290      27              2     18    

22290     27                 2     79                

 

 

after summary : 

 

proc means data=data1 noprint nway;
class group measure;
var c1;
output out=Ave_rates mean=mean; run;

 

 

measure  group    mean

1               1             63

1                 2             70

2                1               67

2                  2            68

3                   1              75

3                  2             86

 

……..

 

30               1            33

30                2            50

 

I want to use proc ttest to tests of significance between two group  for each measure, 

I think I may need write a do loop or macro for ttest, or I need use ttest 30 times. someone help me!

 

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I am guessing that you are looking for something like this:

proc sort data=data1;
   by measure;
run;

proc ttest data=data1;
   by measure;
   class group;
   var c1;
run;

BY group processing, using each value of a variable to perform similar operations, is a core concept in SAS programming.

 

 

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You should be able to use PROC TTEST with a BY MEASURE; statement (which then requires you to sort the data by the MEASURE variable first). You don't need PROC MEANS, you don't need macros, you don't need DO loops.


It is very confusing that you have 30 groups after PROC MEANS but 27 groups before PROC MEANS. Can you explain that?

--
Paige Miller
ballardw
Super User

I am guessing that you are looking for something like this:

proc sort data=data1;
   by measure;
run;

proc ttest data=data1;
   by measure;
   class group;
   var c1;
run;

BY group processing, using each value of a variable to perform similar operations, is a core concept in SAS programming.

 

 

xinyao
Fluorite | Level 6
Thank you so much!
It works!

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
  • 3 replies
  • 1077 views
  • 0 likes
  • 3 in conversation