<?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: Help with prxchange in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392198#M94337</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $;
y=prxchange('s/^([a-z]+)(\d)([a-z]*)$/\10\2\3/i',1,strip(x));
cards;
AA1
AA2a
AA10
AA11a
BB3
BB3b
BB10
BB11b
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 Aug 2017 13:46:13 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-08-31T13:46:13Z</dc:date>
    <item>
      <title>Help with prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392176#M94332</link>
      <description>&lt;P&gt;I have a dataset with a char variable containing the following example values:&lt;/P&gt;&lt;P&gt;AA1&lt;/P&gt;&lt;P&gt;AA2a&lt;/P&gt;&lt;P&gt;AA10&lt;/P&gt;&lt;P&gt;AA11a&lt;/P&gt;&lt;P&gt;BB3&lt;/P&gt;&lt;P&gt;BB3b&lt;/P&gt;&lt;P&gt;BB10&lt;/P&gt;&lt;P&gt;BB11b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially I want to zero-pad the numeric part of each value (e.g. 'AA2a' becomes 'AA02a') and thought the prxchange function would be a quick and simple way of achieving this. &amp;nbsp;However, the problem I have run into is how to reference the zero in the replacement text.&lt;/P&gt;&lt;P&gt;So far&amp;nbsp;the code is similar to:&lt;/P&gt;&lt;P&gt;var2 = prxchange('s/^(\w{2})(\d{1})(\D?)$/$1$2$3/', -1, trim(var1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I reference (and delimit) the zero character in the replacement string&amp;nbsp;of the prxchange function (&lt;SPAN&gt;$1 -&amp;gt;0&amp;lt;- $2$3)?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 12:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392176#M94332</guid>
      <dc:creator>Maurits</dc:creator>
      <dc:date>2017-08-31T12:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392178#M94333</link>
      <description>&lt;P&gt;Never mind, I've managed to find the solution&amp;nbsp;whilst scrawling the interweb!&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those that are interested... use the perl metacharacter \Q which escapes all non-word characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the code becomes:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var2 = prxchange('s/^(\w{2})(\d{1})(\D?)$/$1\Q0$2$3/', -1, trim(var1));&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392178#M94333</guid>
      <dc:creator>Maurits</dc:creator>
      <dc:date>2017-08-31T13:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392198#M94337</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $;
y=prxchange('s/^([a-z]+)(\d)([a-z]*)$/\10\2\3/i',1,strip(x));
cards;
AA1
AA2a
AA10
AA11a
BB3
BB3b
BB10
BB11b
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392198#M94337</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-08-31T13:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392203#M94340</link>
      <description>&lt;P&gt;Thanks for the reply Ksharp but your proposal wouldn't work as the prxchange function would look for the input buffer "\10".&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2017 13:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392203#M94340</guid>
      <dc:creator>Maurits</dc:creator>
      <dc:date>2017-08-31T13:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392504#M94468</link>
      <description>&lt;PRE&gt;
But there are only three buffer.
Did you run my code and see the output?

or try   $10


&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2017 12:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-prxchange/m-p/392504#M94468</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-01T12:15:43Z</dc:date>
    </item>
  </channel>
</rss>

