Hi There
I have a dummy variable "d" and another variable "csrp"
I want use the paired T test to examine, the "csrp" is significant different between "0" and "1" group of "d'.
How should I code it?
Thanks in advance.
Hi @Xinhui
The following code would perform a t-test (mean comparison of two groups defined by the CLASS statement)
proc ttest data=have;
var csrp;
class d;
run;
Are you sure you want to perform a paired t-test? In this case, you need to define the couple of observations between the two groups. Do you have an ID variable to identify pairs?
In this case, you should have two variables (csrp value for each group; a pair by row) and the syntax would be:
proc ttest data=have;
paired csrp1*csrp2;
run;
This was very useful @ed_sas_member , many thanks!
- Dr. Abhijeet Safai
You need to restructure your data so that SAS knows which pairs go together. That means you need your data in a format like this:
ID Pre Post 1 5 8 2 4 8 3 6 7 ....
You can use PROC TRANSPOSE to restructure your data and then run PROC TTEST as indicated by others.
Here's a tutorial on transposing from a long data set to a wide data set with examples that should get you started.
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/
@Xinhui wrote:
Hi There
I have a dummy variable "d" and another variable "csrp"
I want use the paired T test to examine, the "csrp" is significant different between "0" and "1" group of "d'.
How should I code it?
Thanks in advance.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.