<?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: clean the company suffix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550070#M152706</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262815"&gt;@Alexxxxxxx&lt;/a&gt;&amp;nbsp;Have you even tried the code provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;
&lt;P&gt;It should give you the expected result.&lt;/P&gt;
&lt;P&gt;A slightly different alternative that may (or not) suit you better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  RX=prxparse('s/L\. ?T\. ?D\.$/LTD/o');
  set HAVE;
  NEWNAME=prxchange(RX, 1, strip(NAME));
run;      &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;NEWNAME&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE L. T. D.L.T.D. HOUSE CoL. T. D. HOUSE Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The regular expression reads:&lt;/P&gt;
&lt;P&gt;1. Match this:&amp;nbsp; L then dot then optional space then T then dot then optional space then D then dot then end of string&lt;/P&gt;
&lt;P&gt;2. Replace the match with LTD&lt;/P&gt;
&lt;P&gt;Then a request to do this once on the stripped string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lots of RegEx tutorials of the web. That's how I learnt.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2019 02:09:35 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-04-11T02:09:35Z</dc:date>
    <item>
      <title>clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549824#M152617</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to clean the company suffix.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect to 1.check the strings from the back to the front, 2.convert the first L.T.D' or 'L. T. D.' to 'LTD'. 3.(if possible) not convert the 'LTD' when they are the first part of the strings.&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input NAME &amp;amp;:$100.;
infile datalines  missover;
datalines;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.&lt;BR /&gt;L.T.D. HOUSE Co&lt;BR /&gt;L. T. D. HOUSE Co
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I expect to get&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;L.T.D. HOUSE LTD
L. T. D. HOUSE LTD
L. T. D. HOUSE LTD
L.T.D. HOUSE LTD&lt;BR /&gt;L.T.D. HOUSE &lt;BR /&gt;L. T. D. HOUSE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please give me some suggestion about this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Besides, Could you please explain the meaning of 'o'&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rx=prxparse("s/(L\.T\.D\.)$|(L\. *T\. *D\.)$/LTD/o");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to me? and where I can find the explanation of all of this type of word?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 16:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549824#M152617</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-04-10T16:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549838#M152623</link>
      <description>&lt;P&gt;This sniffs of Perl Regular Expressions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your last example is unclear to me:&amp;nbsp; you ignore L.T.D. #1, change L.T.D. #2, ignore L.T.D #3, and remove "Co".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, the below seems to match your described problem, if not your "want" output.&amp;nbsp; This may get you started:&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;:$100.;
infile datalines  missover;
datalines;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.L.T.D. HOUSE CoL. T. D. HOUSE Co
;
run;

data want;
   rx=prxparse("s/(L\.T\.D\.)$|(L\. *T\. *D\.)$/LTD/o");
   set have;
   newname=prxchange(rx,-1,strip(name));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The regular expression says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Substitute matches (the "s")&lt;/P&gt;&lt;P&gt;2) Match on L.T.D.&amp;lt;end of line&amp;gt; or L.&amp;lt;any number of spaces&amp;gt;T.&amp;lt;any number of spaces&amp;gt;D.&amp;lt;end of line&amp;gt;.&amp;nbsp; Note that the period is a Perl metacharacter so I have escaped it via backslash.&amp;nbsp; If you don't want &amp;lt;any number of spaces&amp;gt; remove the asterisks.&lt;/P&gt;&lt;P&gt;3) So, this will only match L.T.D. or L. T. D. (plus additional spaces) when it occurs at the end of line.&lt;/P&gt;&lt;P&gt;4) Make sure you strip "name" since the data value in the PDV will be padded with spaces to the length of the variable (and thus not match &amp;lt;end of line&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Google Perl Regular Expressions or the SAS documentation for more details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S.:&amp;nbsp; Thanks heaps for posting your problem using a working, self contained data step using datalines.&amp;nbsp; It made "my life" much easier!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 04:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549838#M152623</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-04-10T04:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549995#M152675</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate your advice and apologise for my mistake.&lt;/P&gt;&lt;P&gt;please allow me to explain my question in detail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect to&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;1.check the strings from the back to the front, 2.convert the first L.T.D' or 'L. T. D.' ( which I find beginning from the back of strings) 'LTD'. 3.(if possible) not convert the 'LTD' when they are the first part of the strings.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for example,&lt;/SPAN&gt;&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;:$100.;
infile datalines  missover;
datalines;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.
L.T.D. HOUSE Co
L. T. D. HOUSE Co
L. T. D. HOUSE L.T.D. Co 
L. T. D. HOUSE L. T. D. Co
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I expect to get&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;L.T.D. HOUSE LTD
L. T. D. HOUSE LTD
L. T. D. HOUSE LTD
L.T.D. HOUSE LTD

L.T.D. HOUSE Co /the 'L.T.D.' should not be converted as it is at the beginning of the strings*/

L. T. D. HOUSE Co /the 'L.T.D.' should not be converted as it is at the beginning of the strings*/

L. T. D. HOUSE LTD Co /* the first 'LTD' from the back to the front of strings*/

L. T. D. HOUSE LTD Co /* the first 'LTD' from the back to the front of strings*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you give me some suggestion about this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 15:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/549995#M152675</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-04-10T15:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550070#M152706</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262815"&gt;@Alexxxxxxx&lt;/a&gt;&amp;nbsp;Have you even tried the code provided by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;
&lt;P&gt;It should give you the expected result.&lt;/P&gt;
&lt;P&gt;A slightly different alternative that may (or not) suit you better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  RX=prxparse('s/L\. ?T\. ?D\.$/LTD/o');
  set HAVE;
  NEWNAME=prxchange(RX, 1, strip(NAME));
run;      &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;NEWNAME&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE L. T. D.L.T.D. HOUSE CoL. T. D. HOUSE Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The regular expression reads:&lt;/P&gt;
&lt;P&gt;1. Match this:&amp;nbsp; L then dot then optional space then T then dot then optional space then D then dot then end of string&lt;/P&gt;
&lt;P&gt;2. Replace the match with LTD&lt;/P&gt;
&lt;P&gt;Then a request to do this once on the stripped string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lots of RegEx tutorials of the web. That's how I learnt.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 02:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550070#M152706</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-11T02:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550072#M152708</link>
      <description>&lt;P&gt;Now for the second set of data&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; HAVE&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; NAME &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;:&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;100&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;infile&lt;/SPAN&gt; datalines  missover&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.
L.T.D. HOUSE Co
L. T. D. HOUSE Co
L. T. D. HOUSE L.T.D. Co 
L. T. D. HOUSE L. T. D. Co&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would either :&lt;/P&gt;
&lt;P&gt;- Reverse the string (using the function with that name) and reverse the regular expression (i.e. match DTL, not LTD)&lt;/P&gt;
&lt;P&gt;or probably easier&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Ignore the first character of the string (remove it using function substr() and then add it back after the RegEx substitution is applied)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 21:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550072#M152708</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-10T21:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550113#M152726</link>
      <description>&lt;P&gt;I'm really busy with "stuff", so this will be my last reply.&amp;nbsp; If this doesn't meet your needs, then Google and/or the SAS documentation are your friends.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can only go by your sample data.&amp;nbsp; If it is not representative of your actual and complete data, then this may not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your sample data, you always want to convert some aberration of "L.T.D." to "LTD", after the text "HOUSE".&amp;nbsp; If that is representative of your complete data, then this will work.&amp;nbsp; It's not the most robust; if you need a more robust approach, see above, or keep posting and perhaps someone else will spoon feed you the complete solution.&amp;nbsp;&amp;nbsp;&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;:$100.;
infile datalines  missover;
datalines;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.
L.T.D. HOUSE Co
L. T. D. HOUSE Co
L. T. D. HOUSE L.T.D. Co 
L. T. D. HOUSE L. T. D. Co
;
run;

data want;
   rx=prxparse("s/(HOUSE) *(L\. *T\. *D\.)(.*)$/\1 LTD\3/o");
   set have;
   newname=prxchange(rx,-1,strip(name));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 04:06:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/550113#M152726</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-04-11T04:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551913#M153402</link>
      <description>&lt;P&gt;This works too if you only have 2 LTD groups (otherwise use reverse() as mentioned):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input NAME &amp;amp;:$100.;
infile datalines  missover;
datalines;
L.T.D. HOUSE L.T.D.
L. T. D. HOUSE L.T.D.
L. T. D. HOUSE L. T. D.
L.T.D. HOUSE L. T. D.
L.T.D. HOUSE Co
L. T. D. HOUSE Co
L. T. D. HOUSE L.T.D. Co 
L. T. D. HOUSE L. T. D. Co
run;
data WANT;
  RX=prxparse('s/(.+)(L\. ?T\. ?D\.)(.*)/$1LTD$3/o');
  set HAVE;
  NEWNAME=prxchange(RX, 1, strip(NAME));
run;         &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;NAME&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;NEWNAME&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE L.T.D.&lt;/TD&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE L.T.D.&lt;/TD&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE L. T. D.&lt;/TD&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE L. T. D.&lt;/TD&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE LTD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE Co&lt;/TD&gt;
&lt;TD class="l data"&gt;L.T.D. HOUSE Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE Co&lt;/TD&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE L.T.D. Co&lt;/TD&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE L. T. D. Co&lt;/TD&gt;
&lt;TD class="l data"&gt;L. T. D. HOUSE LTD Co&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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;</description>
      <pubDate>Wed, 17 Apr 2019 21:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551913#M153402</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-17T21:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551945#M153415</link>
      <description>&lt;P&gt;Dear &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your kind help. I review my method and data in the past few days, the result&amp;nbsp;may not clear because of my old logic. So, I update the method and divide&amp;nbsp;it into two steps, the first is to process the company suffix if they are at the ending of strings. (which is most common).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input NAME &amp;amp;:$150.;
infile datalines missover;
datalines;
ALARKO GAYRIMENKUL YATIRIM ORTAKLIGI A.S 
HYDRO ALUMINIUM A. S. 
HYDRO ALUMINIUM A.S. 
HYDRO ALUMINIUM A.S 
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can use the following code to unify them to 'AS'.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
NAME_new=prxchange("s/(A\.S\.)$|(A\. *S\.)$|(A\.S)$/ AS /o",-1,strip(NAME));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, I worry about the coincidence that the 'AS' is not a company suffix&amp;nbsp;but a part of a company&amp;nbsp;name. By using the data HAVE as an example,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE2;
input NAME &amp;amp;:$150.;
infile datalines missover;
datalines;
ALARKO GAYRIMENKUL YATIRIM ORTAKLIGI X.A.S 
HYDRO ALUMINIUM X. A. S. 
HYDRO ALUMINIUM X.A.S. 
HYDRO ALUMINIUM X.A.S 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the strings '&lt;CODE class=" language-sas"&gt;X.A.S' or 'X. A. S.' which writen in the same format, are assumed to be a word, so they should not proceed. however, I get the following result by code,&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;NAME&lt;/TD&gt;&lt;TD&gt;NAME6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ALARKO GAYRIMENKUL YATIRIM ORTAKLIGI X.A.S&lt;/TD&gt;&lt;TD&gt;ALARKO GAYRIMENKUL YATIRIM ORTAKLIGI X. AS&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HYDRO ALUMINIUM X. A. S.&lt;/TD&gt;&lt;TD&gt;HYDRO ALUMINIUM X. AS&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HYDRO ALUMINIUM X.A.S.&lt;/TD&gt;&lt;TD&gt;HYDRO ALUMINIUM X. AS&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HYDRO ALUMINIUM X.A.S&lt;/TD&gt;&lt;TD&gt;HYDRO ALUMINIUM X. AS&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;How can I fix this problem? Could you please give me some suggestions about this? THX&amp;nbsp; in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 16:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551945#M153415</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-04-18T16:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551966#M153427</link>
      <description>&lt;P&gt;&lt;A href="https://www.google.com/search?q=online+regex+builder" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.google.com/search?q=online+regex+builder&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try a few, decide which one works best for you.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 02:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551966#M153427</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-04-18T02:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551982#M153435</link>
      <description>&lt;P&gt;From what you are now showing, you have to look at the preceding characters (and ensure they are not dot or dot-space).&lt;/P&gt;
&lt;P&gt;This is done by using a negative look-behind assertion. The RegEx syntax is &lt;FONT face="courier new,courier"&gt;(?&amp;lt;! )&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 04:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/551982#M153435</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-18T04:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552196#M153500</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do you meaning&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;data want;
set have;
NAME_new=prxchange("s/(?&amp;lt;! )(A\.S\.)$|(?&amp;lt;! )(A\. *S\.)$|(?&amp;lt;! )(A\.S)$/ AS /o",-1,strip(NAME));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it does not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 17:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552196#M153500</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-04-18T17:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552197#M153501</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15043"&gt;@ScottBass&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your recommendation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have started to use this and tried a lot of times, but not work. Could you please give me some suggestions about the code?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 17:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552197#M153501</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-04-18T17:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552591#M153608</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; But it does not work.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262815"&gt;@Alexxxxxxx&lt;/a&gt; You have been supplied with many examples of regular expressions -and their explanation-&amp;nbsp; as you kept updating the requirements for your data in successive posts. It is now time that you learn how to write your own.&lt;/P&gt;
&lt;P&gt;Search the web for&lt;FONT face="courier new,courier"&gt; negative look-behind assertion&lt;/FONT&gt; to obtain countless examples and tutorials. The syntax you provide does not do what you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my opinion, the step even before that would be to define exactly what you need.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2019 04:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-suffix/m-p/552591#M153608</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-04-20T04:03:23Z</dc:date>
    </item>
  </channel>
</rss>

