<?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: prxchange replace multiple matches in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629901#M186409</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this answer your question?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  have=prxchange('s/(a|g|f)/$1$1/',-1,'sasgf');
  put have=;
  put 'want=saasggff';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; 71         data _null_;
 72           have=prxchange('s/(a|g|f)/$1$1/',-1,'sasgf');
 73           put have=;
 74           put 'want=saasggff';
 75         run;
 
 have=saasggff
 want=saasggff&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Mar 2020 18:15:28 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-03-05T18:15:28Z</dc:date>
    <item>
      <title>prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629899#M186407</link>
      <description>&lt;P&gt;Can anyone help me with this little puzzle?&amp;nbsp; I'm trying to use capture buffers to perform conditional replacement of multiple values in a single pass.&amp;nbsp; The replaced values are two characters (versus the single character I'm matching) so I can't use translate.&amp;nbsp; I could use multiple instances of tranwrd (or nest the prxchange), but I'm keen to know - is a single pass possible?&amp;nbsp; I do not know the length or content of my input values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  have=prxchange('s/a|g|f/$1aa$2gg$3ff/',-1,'sasgf');
  put have=;
  put 'want=saasggff';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;PRE&gt; have=saaggffsaaggffaaggff
 want=saasggff&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt; - to clarify, the values on the right should be anything, eg:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 73         data _null_;
 74           have=prxchange('s/a|g|f/$1xx$2yy$3zz/',-1,'sasgf');
 75           put have=;
 76           put 'want=sxxsyyzz';
 77         run;
 
 have=sxxyyzzsxxyyzzxxyyzz
 want=sxxsyyzz&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629899#M186407</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2020-03-05T18:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629901#M186409</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this answer your question?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  have=prxchange('s/(a|g|f)/$1$1/',-1,'sasgf');
  put have=;
  put 'want=saasggff';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; 71         data _null_;
 72           have=prxchange('s/(a|g|f)/$1$1/',-1,'sasgf');
 73           put have=;
 74           put 'want=saasggff';
 75         run;
 
 have=saasggff
 want=saasggff&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629901#M186409</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-05T18:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629902#M186410</link>
      <description>&lt;P&gt;thanks for the quick response! You solved the puzzle (as it was set)&amp;nbsp;but I'm still stuck. The replacement values could be anything (I should have picked better examples)&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629902#M186410</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2020-03-05T18:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629906#M186412</link>
      <description>&lt;P&gt;No problem&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide some representative sample data?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629906#M186412</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-05T18:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629907#M186413</link>
      <description>&lt;P&gt;done&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629907#M186413</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2020-03-05T18:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629912#M186414</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an attempt to achieve this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ref;
	input match $ replace $;
	datalines;
a xx
g yy
f zz
;	

data _null_;
	set ref end=eof;
	length have $ 30;
	if _n_=1 then have = 'sasgf';
	retain have;
	have=prxchange(cats('s/',match,'/',replace,'/'),-1,have);
	if eof then do;
		put have=;
		put 'want=sxxsyyzz';
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629912#M186414</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-05T18:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629914#M186415</link>
      <description>&lt;P&gt;ha ha - ok.&amp;nbsp; From what I can tell, it is not possible to do what I am trying to do.&amp;nbsp; But I admire the approach you took to avoid nesting the regex calls &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;accepted.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 18:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629914#M186415</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2020-03-05T18:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629917#M186417</link>
      <description>You’re welcome &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt; !</description>
      <pubDate>Thu, 05 Mar 2020 18:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/629917#M186417</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-05T18:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: prxchange replace multiple matches</title>
      <link>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/707660#M217301</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28909"&gt;@AllanBowe&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Is this what you were looking for?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;28 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;29 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/*&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;have=prxchange('s/a|g|f/$1aa$2gg$3ff/',-1,'sasgf');*/&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;30 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/*&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;put have=;*/&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;31 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;put 'want=saasggff';&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;32 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;have=prxchange('s/&lt;FONT color="#339966"&gt;&lt;STRONG&gt;(a|g|f){1}?&lt;/STRONG&gt;&lt;/FONT&gt;/&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;$1$1&lt;/FONT&gt;&lt;/STRONG&gt;/',-1,'sasgf');&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;33 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;put have=;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;34 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;want=saasggff&lt;/P&gt;&lt;P class="p1"&gt;have=saasggff&lt;/P&gt;&lt;P class="p2"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;36 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;37 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/*have=prxchange('s/a|g|f/$1xx$2yy$3zz/',-1,'sasgf');*/&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;38 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/*put have=;*/&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;39 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;put 'want=sxxsyyzz';&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;40 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;have=prxchange('s/&lt;FONT color="#339966"&gt;&lt;STRONG&gt;([^agf]*)(a){1}?([^agf]*)(g){1}?([^agf]*)(f){1}?&lt;/STRONG&gt;&lt;/FONT&gt;/&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;$1xx$3yy$5zz&lt;/STRONG&gt;&lt;/FONT&gt;/',-1,'sasgf');&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;41 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;put have=;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier" size="3"&gt;42 &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;want=sxxsyyzz&lt;/P&gt;&lt;P class="p1"&gt;have=sxxsyyzz&lt;/P&gt;&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;The former prxchange works, but only if you want to duplicate specific characters in an input string.&lt;/P&gt;&lt;P class="p1"&gt;But I guess that's not exactly what you were after... The latter prxchange should be closer to meet your requirements.&amp;nbsp;&lt;/P&gt;&lt;P class="p1"&gt;So the $64k question is: does it?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 13:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/prxchange-replace-multiple-matches/m-p/707660#M217301</guid>
      <dc:creator>rafgag</dc:creator>
      <dc:date>2020-12-22T13:51:13Z</dc:date>
    </item>
  </channel>
</rss>

