BookmarkSubscribeRSS Feed
Banke
Pyrite | Level 9
ID sex diasbp male_diasbp female_diasbp
1 1 45 45 .
2 1 54 54 .
3 2 65 . 65
4 2 68 . 68
data biostat.original;
input id sex diasp;
data lines
1 1 65
2 2 45
3 2 78
4 2 50
5 1 49

data biostat.male_dbp biostat.female_dbp; set biostat.dig200; if sex = 1 then output biostat.male_dbp; else output biostat.female_dbp; run; data biostat.male_dbp1; set biostat.male_dbp; male_diabp = diabp; run; data biostat.female_dbp1; set biostat.female_dbp; female_diabp = diabp; run; proc sort data = biostat.male_dbp1; by ID; run; proc sort data = biostat.female_dbp1; by ID; run; data biostat.dbp_grps; merge biostat.male_dbp1 biostat.female_dbp1; by ID; run;

proc ttest;
paired male_diabp*female_diabp;
run;

Hello everyone, here again😊

i want to conduct an hypothesis test on the mean difference between male and female diastolic blood pressures (diabp). This would require a paired ttest, hence 2 paired variables considering the syntax...

I have the diabp in just one variable and there is another variable for sex (coded 1 and 2 for male and female respectively), to get malediabp and femalediabp into 2 different variables , i first output each of them into different datasets and merged by a common variable (ID). The step is however long, i would please like to know if there is a more efficient way of doing this. Thanks

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I have to disagree, if you want to test the mean diastolic blood pressure difference between males and females, you want an UNpaired t-test.

 

A paired t-test in this case does not make sense and does not fit the experiment.

--
Paige Miller
Banke
Pyrite | Level 9
Oops! You are right, there is no pairing between them, they are independent of each other. Thanks
ballardw
Super User

@Banke wrote:
Oops! You are right, there is no pairing between them, they are independent of each other. Thanks

Unless you have that many sex-change operations in your subject pool...

Reeza
Super User

Please fix your code before posting. The first two steps do not work when tested.

 

As also indicated by PaigeMiller, given what you've posted here this does not align with a paired t-test. A paired t-test is usually used for repeated measurements on the same individual. In this case you have data on different individuals and should run a standard t-test. If you do want to restructure your data to a wide format for a paired t-test though you should look into PROC TRANSPOSE.

 

Transposing data tutorials:
Long to Wide:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/

Wide to Long:
https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/

https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/

And sometimes a double transpose is needed for extra wide data sets:
https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd

 


@Banke wrote:
ID sex diasbp male_diasbp female_diasbp
1 1 45 45 .
2 1 54 54 .
3 2 65 . 65
4 2 68 . 68
data biostat.original;
input id sex diasp;
data lines
1 1 65
2 2 45
3 2 78
4 2 50
5 1 49

data biostat.male_dbp biostat.female_dbp; set biostat.dig200; if sex = 1 then output biostat.male_dbp; else output biostat.female_dbp; run; data biostat.male_dbp1; set biostat.male_dbp; male_diabp = diabp; run; data biostat.female_dbp1; set biostat.female_dbp; female_diabp = diabp; run; proc sort data = biostat.male_dbp1; by ID; run; proc sort data = biostat.female_dbp1; by ID; run; data biostat.dbp_grps; merge biostat.male_dbp1 biostat.female_dbp1; by ID; run;

proc ttest;
paired male_diabp*female_diabp;
run;

Hello everyone, here again😊

i want to conduct an hypothesis test on the mean difference between male and female diastolic blood pressures (diabp). This would require a paired ttest, hence 2 paired variables considering the syntax...

I have the diabp in just one variable and there is another variable for sex (coded 1 and 2 for male and female respectively), to get malediabp and femalediabp into 2 different variables , i first output each of them into different datasets and merged by a common variable (ID). The step is however long, i would please like to know if there is a more efficient way of doing this. Thanks


 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 657 views
  • 2 likes
  • 4 in conversation