<?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: Calculating combinations in test results in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937049#M46755</link>
    <description>&lt;P&gt;A minor addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; 's suggestion: add ORDER=FREQ to the proc statement. That will have the most common "combination" appear at the top of the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some types of analysis you may want to consider variables that are numeric 1/0 for Positive/negative.&lt;/P&gt;
&lt;P&gt;Then things like the SUM indicate the number of Positive, so if the SUM is the number of variables tested you get "all positive" or if SUM is 0 then all negative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example: The first step is just to get data similar to yours, the second is to create numeric versions, then one way to count specific totals.&lt;/P&gt;
&lt;PRE&gt;data have;
   input SampleID $	Test_1 $	Test_2 $	Test_3 $;
datalines;
1	positive	positive	negative
2	positive	positive	negative
3	negative	negative	negative
4	negative	negative	positive
;

data useful;
   set have;
   array t (*) Test_: ;
   array nt (*) nt_1 - nt_3;
   do i=1 to dim(t);
      nt[i] = t[i]='positive';
   end;
   drop i;
run;

proc means data=useful n;
   where sum(nt_1, nt_2)=2;
   var nt_1;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or all the same:&lt;/P&gt;
&lt;PRE&gt;proc freq data=useful;
  where range(nt_1,nt_2,nt_3)=0;
  tables test_1*test_2*test_3 /list;
run;
&lt;/PRE&gt;
&lt;P&gt;The various functions, SUM, Max, Min, Range basically can allow different sorts of if to be written simply&lt;/P&gt;
&lt;P&gt;SUM = (specific number of positive), Sum &amp;gt; X&amp;nbsp; means at least X positive,&lt;/P&gt;
&lt;P&gt;MAX= 1 at least one of the values is positive&lt;/P&gt;
&lt;P&gt;Min=0 at least one of the values is negative&lt;/P&gt;
&lt;P&gt;Range=0 all the same, Range=1 some mixture of positive and negative&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 19:20:26 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-07-24T19:20:26Z</dc:date>
    <item>
      <title>Calculating combinations in test results</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937039#M46753</link>
      <description>&lt;P&gt;I am trying to calculate the most common combination of tests combination and test results,&lt;/P&gt;&lt;P&gt;For example I would like to know the count of how many times Test_1 was taken with Test_2 and both positive... There is over 300+ samples with over 100+ tests, and it has been difficult to find a solution/code on how to simply output this. I've tried proc freq to get the individual counts, but that only gets me so far. Any advice?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sample ID&lt;/TD&gt;&lt;TD&gt;Test_1&lt;/TD&gt;&lt;TD&gt;Test_2&lt;/TD&gt;&lt;TD&gt;Test_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;positive&lt;/TD&gt;&lt;TD&gt;positive&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;negative&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;positive&lt;/TD&gt;&lt;TD&gt;positive&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;TD&gt;negative&lt;/TD&gt;&lt;TD&gt;positive&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&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;</description>
      <pubDate>Wed, 24 Jul 2024 17:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937039#M46753</guid>
      <dc:creator>rabbit_hole13</dc:creator>
      <dc:date>2024-07-24T17:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating combinations in test results</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937042#M46754</link>
      <description>&lt;P&gt;Since you don't really say what you will want to do with Test_3, I will just make an assumption that it will be handled as combinations of pos/neg for all three variables. Please confirm that is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will do the counting you describe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    tables test_1*test_2*test_3/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have 100 variables, then somehow you need to whittle the process down, and do analyses on a manageable portion of these 100 variables.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 18:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937042#M46754</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-24T18:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating combinations in test results</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937049#M46755</link>
      <description>&lt;P&gt;A minor addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; 's suggestion: add ORDER=FREQ to the proc statement. That will have the most common "combination" appear at the top of the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some types of analysis you may want to consider variables that are numeric 1/0 for Positive/negative.&lt;/P&gt;
&lt;P&gt;Then things like the SUM indicate the number of Positive, so if the SUM is the number of variables tested you get "all positive" or if SUM is 0 then all negative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example: The first step is just to get data similar to yours, the second is to create numeric versions, then one way to count specific totals.&lt;/P&gt;
&lt;PRE&gt;data have;
   input SampleID $	Test_1 $	Test_2 $	Test_3 $;
datalines;
1	positive	positive	negative
2	positive	positive	negative
3	negative	negative	negative
4	negative	negative	positive
;

data useful;
   set have;
   array t (*) Test_: ;
   array nt (*) nt_1 - nt_3;
   do i=1 to dim(t);
      nt[i] = t[i]='positive';
   end;
   drop i;
run;

proc means data=useful n;
   where sum(nt_1, nt_2)=2;
   var nt_1;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or all the same:&lt;/P&gt;
&lt;PRE&gt;proc freq data=useful;
  where range(nt_1,nt_2,nt_3)=0;
  tables test_1*test_2*test_3 /list;
run;
&lt;/PRE&gt;
&lt;P&gt;The various functions, SUM, Max, Min, Range basically can allow different sorts of if to be written simply&lt;/P&gt;
&lt;P&gt;SUM = (specific number of positive), Sum &amp;gt; X&amp;nbsp; means at least X positive,&lt;/P&gt;
&lt;P&gt;MAX= 1 at least one of the values is positive&lt;/P&gt;
&lt;P&gt;Min=0 at least one of the values is negative&lt;/P&gt;
&lt;P&gt;Range=0 all the same, Range=1 some mixture of positive and negative&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 19:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937049#M46755</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-24T19:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating combinations in test results</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937063#M46760</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;A minor addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; 's suggestion: add ORDER=FREQ to the proc statement. That will have the most common "combination" appear at the top of the output.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;: That would be useful. But I think you need to sort the OUT= dataset &lt;FONT face="courier new,courier"&gt;by descending count&lt;/FONT&gt; to obtain the desired sort order. The printed output of&lt;/P&gt;
&lt;PRE&gt;tables test_1*test_2*test_3 / list;&lt;/PRE&gt;
&lt;P&gt;with ORDER=FREQ in effect is only sorted by descending &lt;EM&gt;one-way&lt;/EM&gt; frequencies of the three variables: by&amp;nbsp;descending frequencies of TEST_1, descending frequencies of TEST_2 (alone, not depending on the levels of TEST_1) and descending frequencies of TEST_3 (unless this has changed after SAS release 9.4M5).&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 20:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Calculating-combinations-in-test-results/m-p/937063#M46760</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-07-24T20:49:27Z</dc:date>
    </item>
  </channel>
</rss>

