<?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: convert A. S. to AS by prxchange in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556137#M154883</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; name_S33=prxchange("s/\bA\. *\bS\./AS/oi",1, name);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RegEx you've posted should work as well if you add strip(name) as else there will be trailing blanks in your string and the first bit of your RegEx will never match (the $ at the end means the of string so any trailing blank will render this as a non-match).&lt;/P&gt;
&lt;PRE&gt;name_S33=prxchange("s/ A\. *S\.$| A\.S\.*/ AS /o",1, strip(name));&lt;/PRE&gt;</description>
    <pubDate>Sat, 04 May 2019 02:31:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-05-04T02:31:55Z</dc:date>
    <item>
      <title>convert A. S. to AS by prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556134#M154880</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to convert A. S. to AS by following codes. However, the code works well by the online regex but not through SAS. Could you please give me some suggestions about this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input name &amp;amp;:$300.;
infile datalines  missover;
datalines;
BUXTON, WILLIAM A. S.
SOL, ALISSON A. S.
BUXTON, WILLIAM A. S.
BUXTON A.S. WILLIAM
;
run;

data want;
	set HAVE;
name_S33=prxchange("s/ A\. *S\.$| A\.S\.*/ AS /o",1, name);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 01:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556134#M154880</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-05-04T01:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: convert A. S. to AS by prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556136#M154882</link>
      <description>&lt;P&gt;Try using \b to detect word boundary and don't refer to the string end ($) as the string is 300 chars long:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"s/\bA\.\s?S\./AS/o"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 02:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556136#M154882</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-05-04T02:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: convert A. S. to AS by prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556137#M154883</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; name_S33=prxchange("s/\bA\. *\bS\./AS/oi",1, name);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RegEx you've posted should work as well if you add strip(name) as else there will be trailing blanks in your string and the first bit of your RegEx will never match (the $ at the end means the of string so any trailing blank will render this as a non-match).&lt;/P&gt;
&lt;PRE&gt;name_S33=prxchange("s/ A\. *S\.$| A\.S\.*/ AS /o",1, strip(name));&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 May 2019 02:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556137#M154883</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-04T02:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: convert A. S. to AS by prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556200#M154927</link>
      <description>&lt;P&gt;SAS stores all character variables as fixed length. So shorter values are padded with spaces. So by using the $ symbol one of your patterns will only match strings with a period in position 300.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But your RegEx can be simplified.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prxchange("s/ *A\. *S\. */ AS /o",1, name)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  infile datalines  truncover;
  input name $300.;
datalines;
BUXTON, WILLIAM A. S.
SOL, ALISSON A. S.
BUXTON, WILLIAM A. S.
BUXTON A.S. WILLIAM
BUXTON   A.   S.   WILLIAM
;

data want;
  set HAVE;
  name_S33=prxchange("s/ *A\. *S\. */ AS /o",1, name);
  put name :$quote. '-&amp;gt; ' name_s33 :$quote.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;"BUXTON, WILLIAM A. S." -&amp;gt; "BUXTON, WILLIAM AS"
"SOL, ALISSON A. S." -&amp;gt; "SOL, ALISSON AS"
"BUXTON, WILLIAM A. S." -&amp;gt; "BUXTON, WILLIAM AS"
"BUXTON A.S. WILLIAM" -&amp;gt; "BUXTON AS WILLIAM"
"A.S. WILLIAM BUXTON" -&amp;gt; " AS WILLIAM BUXTON"
"BUXTON   A.   S.   WILLIAM" -&amp;gt; "BUXTON AS WILLIAM"&lt;/PRE&gt;
&lt;P&gt;You might want to add a LEFT() function to eliminate that leading space on my next to last example.&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 16:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-A-S-to-AS-by-prxchange/m-p/556200#M154927</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-04T16:50:12Z</dc:date>
    </item>
  </channel>
</rss>

