<?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 Comparing matched independent variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839603#M41596</link>
    <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS. First of all, here is a sample of the data:&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Pairs&lt;/TD&gt;&lt;TD&gt;Instrument type&lt;/TD&gt;&lt;TD&gt;Issuer name (same)&lt;/TD&gt;&lt;TD&gt;YTM&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;3,459742&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;2.8651&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;3,464001&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;2,2493&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;2,6682&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;4,623&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;2,752&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;3,86234&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to do a descriptive statistics to compare A and B.&amp;nbsp; A and B must be from the same issuer. To do so, I formed pairs.&amp;nbsp;&lt;BR /&gt;I couldn't&amp;nbsp; find a command that would give the mean difference between the YTMs of A and B as follows : YTMb A (i)-YTM B (i) where i is the pair.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Logically, I would use the proc ttest but the difference in YTM must be only from the same pair.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the result, the diff(A-B) should be only based on a two by two difference from the same pair.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope I am clear.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2022 09:52:34 GMT</pubDate>
    <dc:creator>Emna1</dc:creator>
    <dc:date>2022-10-20T09:52:34Z</dc:date>
    <item>
      <title>Comparing matched independent variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839603#M41596</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS. First of all, here is a sample of the data:&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Pairs&lt;/TD&gt;&lt;TD&gt;Instrument type&lt;/TD&gt;&lt;TD&gt;Issuer name (same)&lt;/TD&gt;&lt;TD&gt;YTM&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;3,459742&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;2.8651&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;3,464001&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;2,2493&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;2,6682&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;4,623&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;2,752&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;T&lt;/TD&gt;&lt;TD&gt;3,86234&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to do a descriptive statistics to compare A and B.&amp;nbsp; A and B must be from the same issuer. To do so, I formed pairs.&amp;nbsp;&lt;BR /&gt;I couldn't&amp;nbsp; find a command that would give the mean difference between the YTMs of A and B as follows : YTMb A (i)-YTM B (i) where i is the pair.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Logically, I would use the proc ttest but the difference in YTM must be only from the same pair.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the result, the diff(A-B) should be only based on a two by two difference from the same pair.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope I am clear.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 09:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839603#M41596</guid>
      <dc:creator>Emna1</dc:creator>
      <dc:date>2022-10-20T09:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing matched independent variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839604#M41597</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436449"&gt;@Emna1&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&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/436449"&gt;@Emna1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Logically, I would use the proc ttest ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a great idea. The &lt;A href="https://documentation.sas.com/doc/en/statug/15.2/statug_ttest_syntax08.htm" target="_blank" rel="noopener"&gt;PAIRED statement&lt;/A&gt; of the TTEST procedure requires the YTM values of A and B to be in separate variables so that each observation of the input dataset represents one pair. You can use &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xno5xgs39b70n0zydov0owajj8.htm" target="_blank" rel="noopener"&gt;PROC TRANSPOSE&lt;/A&gt; to reshape the data in this way -- assuming that you already have a SAS dataset (like dataset HAVE in the code below) containing the data shown in your table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have;
input pair instrument_type $ issuer_name $ YTM :numx.;
cards;
1 A X 3,459742
1 B X 2,8651
2 A Y 3,464001
2 B Y 2,2493
3 A Z 2,6682
3 B Z 4,623
4 A T 2,752
4 B T 3,86234
;

/* Reshape the data for PROC TTEST */

proc transpose data=have out=want;
by pair issuer_name; /* alternatively: by issuer_name notsorted; */
id instrument_type;
var YTM;
run;

/* Use PROC TTEST to compute descriptive statistics for A-B */

proc ttest data=want;
paired A*B;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 10:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839604#M41597</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-10-20T10:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing matched independent variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839618#M41598</link>
      <description>&lt;P&gt;This is exactly what I asked for. Thank you very much for your help !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 12:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Comparing-matched-independent-variables/m-p/839618#M41598</guid>
      <dc:creator>Emna1</dc:creator>
      <dc:date>2022-10-20T12:02:32Z</dc:date>
    </item>
  </channel>
</rss>

