2
votes

I have data which looks like following. I was wondering how to run a t-test when variables that I want to compare are in different columns

+---------+------------+----------+-------------+-------------+----------------+
| Case_id | Control_id | case_age | control_age | case_result | control_result |
+---------+------------+----------+-------------+-------------+----------------+
|       1 |         50 |       24 |          24 |          23 |             12 |
|       1 |         52 |       24 |          24 |          23 |             10 |
|       2 |         65 |       27 |          27 |          24 |             15 |
|       2 |         70 |       27 |          27 |          24 |             14 |
+---------+------------+----------+-------------+-------------+----------------+

The SAS tutorials indicate the following syntax for running a t-test. But in my case I do not have a class variable to distinguish between cases and control. Is there a way to tell SAS to compare two variables case_result and control_result.

proc ttest data;
   class Gender;
   var Score;
run;
1

1 Answers

3
votes

If you would like to compare two variables, it can be done this way:

proc compare base=libname.dataset allstats briefsummary;    
       var var1;
       with var2;
       title 'Comparison two variables';
run;

To run ttest on difference b/w two variables (paired comparison),

proc ttest data=libname.dataset;
   paired var1*var2;
run;