<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating 2 variables from one for paired ttest in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773741#M31197</link>
    <description>&lt;P&gt;Please fix your code before posting. The first two steps do not work when tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And sometimes a double transpose is needed for extra wide data sets:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd" target="_blank"&gt;https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE border="1" width="69.44424256262148%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;ID&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;sex&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;male_diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;female_diasbp&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;3&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;4&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data biostat.original;&lt;BR /&gt;input id sex diasp;&lt;BR /&gt;data lines&lt;BR /&gt;1  1  65&lt;BR /&gt;2  2  45  &lt;BR /&gt;3  2  78&lt;BR /&gt;4  2  50&lt;BR /&gt;5  1  49&lt;BR /&gt;&lt;BR /&gt;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;&lt;BR /&gt;&lt;BR /&gt;proc ttest;&lt;BR /&gt;paired male_diabp*female_diabp;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello everyone, here again&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 19:46:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-12T19:46:10Z</dc:date>
    <item>
      <title>Creating 2 variables from one for paired ttest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773727#M31193</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE border="1" width="69.44424256262148%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;ID&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;sex&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;male_diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;female_diasbp&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;3&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;4&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data biostat.original;&lt;BR /&gt;input id sex diasp;&lt;BR /&gt;data lines&lt;BR /&gt;1  1  65&lt;BR /&gt;2  2  45  &lt;BR /&gt;3  2  78&lt;BR /&gt;4  2  50&lt;BR /&gt;5  1  49&lt;BR /&gt;&lt;BR /&gt;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;&lt;BR /&gt;&lt;BR /&gt;proc ttest;&lt;BR /&gt;paired male_diabp*female_diabp;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello everyone, here again&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773727#M31193</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-10-12T19:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating 2 variables from one for paired ttest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773730#M31194</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A paired t-test in this case does not make sense and does not fit the experiment.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773730#M31194</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-12T19:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating 2 variables from one for paired ttest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773735#M31195</link>
      <description>Oops! You are right, there is no pairing between them, they are independent of each other. Thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773735#M31195</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-10-12T19:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating 2 variables from one for paired ttest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773740#M31196</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Oops! You are right, there is no pairing between them, they are independent of each other. Thanks&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unless you have that many sex-change operations in your subject pool...&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773740#M31196</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-12T19:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating 2 variables from one for paired ttest</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773741#M31197</link>
      <description>&lt;P&gt;Please fix your code before posting. The first two steps do not work when tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transposing data tutorials:&lt;BR /&gt;Long to Wide:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Wide to Long:&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-wide-to-long-using-proc-transpose/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-wide-to-long-using-a-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And sometimes a double transpose is needed for extra wide data sets:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd" target="_blank"&gt;https://gist.github.com/statgeek/2321b6f62ab78d5bf2b0a5a8626bd7cd&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE border="1" width="69.44424256262148%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;ID&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;sex&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;male_diasbp&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;female_diasbp&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;45&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;1&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;54&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;3&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;65&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="16.666666666666668%"&gt;4&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;2&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;.&lt;/TD&gt;
&lt;TD width="16.666666666666668%"&gt;68&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data biostat.original;&lt;BR /&gt;input id sex diasp;&lt;BR /&gt;data lines&lt;BR /&gt;1  1  65&lt;BR /&gt;2  2  45  &lt;BR /&gt;3  2  78&lt;BR /&gt;4  2  50&lt;BR /&gt;5  1  49&lt;BR /&gt;&lt;BR /&gt;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;&lt;BR /&gt;&lt;BR /&gt;proc ttest;&lt;BR /&gt;paired male_diabp*female_diabp;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello everyone, here again&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-2-variables-from-one-for-paired-ttest/m-p/773741#M31197</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-12T19:46:10Z</dc:date>
    </item>
  </channel>
</rss>

