<?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 prxmatch &amp;amp; arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620623#M182385</link>
    <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about the use of prxmatch and arrays.&lt;/P&gt;&lt;P&gt;I have a list with multiple different therapies (treat1-treat15). I want to select all chemotherapies from this list and combine different types of chemo that are given as combination therapy. I wrote the syntax below. This works for comparing treat{i} and treat{i+1}, but I also want to compare treat{i} with treat{i+2}, treat{i+3} etc. And preferably also compare treat{i} with treat{i+1} and treat {i+3} at the same time, as there might be up to three or four chemotherapies that need to be combined. Is there an easy way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let chemo = XY40|BC50|XA60|ZL90|OX15|MZ78;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data twee;&lt;BR /&gt;set een;&lt;/P&gt;&lt;P&gt;array treat15} $ treat1 - treat15;&lt;BR /&gt;array treat_dat{15} treat_dat1 - treat_dat15;&lt;/P&gt;&lt;P&gt;array CT{15}&amp;nbsp; &amp;nbsp;CT1-CT15;&lt;/P&gt;&lt;P&gt;array CT_dat{15} CT_dat1-CT_dat15;&lt;/P&gt;&lt;P&gt;CT=0;&lt;/P&gt;&lt;P&gt;do i=1 to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if prxmatch("m/&amp;amp;chemo/i", treat{i})&amp;gt;0 and prxmatch("m/&amp;amp;chemo/i", treat{i+1})&amp;gt;0&lt;/P&gt;&lt;P&gt;and treat_dat{i}=treat_dat{i+1} then do;&lt;/P&gt;&lt;P&gt;if treat{i}=XY40 and treat{i+1}=BC50 then do; CT{i}=OX15; CT_dat{i}=treat_dat{i}; end;&lt;/P&gt;&lt;P&gt;if treat{i}=XY40 and treat{i+1}=XA60 then do;&amp;nbsp;CT{i}=MZ78; CT_dat{i}=treat_dat{i}; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2020 19:17:56 GMT</pubDate>
    <dc:creator>Appelsap</dc:creator>
    <dc:date>2020-01-28T19:17:56Z</dc:date>
    <item>
      <title>prxmatch &amp; arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620623#M182385</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question about the use of prxmatch and arrays.&lt;/P&gt;&lt;P&gt;I have a list with multiple different therapies (treat1-treat15). I want to select all chemotherapies from this list and combine different types of chemo that are given as combination therapy. I wrote the syntax below. This works for comparing treat{i} and treat{i+1}, but I also want to compare treat{i} with treat{i+2}, treat{i+3} etc. And preferably also compare treat{i} with treat{i+1} and treat {i+3} at the same time, as there might be up to three or four chemotherapies that need to be combined. Is there an easy way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let chemo = XY40|BC50|XA60|ZL90|OX15|MZ78;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data twee;&lt;BR /&gt;set een;&lt;/P&gt;&lt;P&gt;array treat15} $ treat1 - treat15;&lt;BR /&gt;array treat_dat{15} treat_dat1 - treat_dat15;&lt;/P&gt;&lt;P&gt;array CT{15}&amp;nbsp; &amp;nbsp;CT1-CT15;&lt;/P&gt;&lt;P&gt;array CT_dat{15} CT_dat1-CT_dat15;&lt;/P&gt;&lt;P&gt;CT=0;&lt;/P&gt;&lt;P&gt;do i=1 to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if prxmatch("m/&amp;amp;chemo/i", treat{i})&amp;gt;0 and prxmatch("m/&amp;amp;chemo/i", treat{i+1})&amp;gt;0&lt;/P&gt;&lt;P&gt;and treat_dat{i}=treat_dat{i+1} then do;&lt;/P&gt;&lt;P&gt;if treat{i}=XY40 and treat{i+1}=BC50 then do; CT{i}=OX15; CT_dat{i}=treat_dat{i}; end;&lt;/P&gt;&lt;P&gt;if treat{i}=XY40 and treat{i+1}=XA60 then do;&amp;nbsp;CT{i}=MZ78; CT_dat{i}=treat_dat{i}; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 19:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620623#M182385</guid>
      <dc:creator>Appelsap</dc:creator>
      <dc:date>2020-01-28T19:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: prxmatch &amp; arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620628#M182389</link>
      <description>&lt;P&gt;Without sample data it is hard to get a sense of what you are doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it sounds like you just need another DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DO I=1 to 15 ;
  DO J=I+1 to 15;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can compare the Ith variable in the array to the Jth variable in the array.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 19:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620628#M182389</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-28T19:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: prxmatch &amp; arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620674#M182417</link>
      <description>&lt;P&gt;You likely will need a much larger OUTPUT array. Consider comparing 4 items:&lt;/P&gt;
&lt;P&gt;A B C D&lt;/P&gt;
&lt;P&gt;The pairwise comparisons are&lt;/P&gt;
&lt;P&gt;AB AC AD BC BD CD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The function comb will give the number of elements you may need:&lt;/P&gt;
&lt;PRE&gt;data example;
   needed = comb(15,2);
run;&lt;/PRE&gt;
&lt;P&gt;which will yield 105 combinations taken 2 at a time. Do you need to consider 3 at a time? That would be 455.&lt;/P&gt;
&lt;P&gt;And if the ORDER encountered is important, where AB is different from BA in my starting discussion, then you need Permutations with the function Perm to get the number of permutations (210 for 15 taken 2 at time).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your comparisons also will fail. To compare values:if treat{i}=XY40&amp;nbsp;is going to look for a variable named XY40. You should be using quoted literal values:&lt;/P&gt;
&lt;P&gt;if treat{i}="XY40"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to look at the combinatorial functions ALLCOMB or Call Allcomb.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 21:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxmatch-amp-arrays/m-p/620674#M182417</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-28T21:35:18Z</dc:date>
    </item>
  </channel>
</rss>

