<?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 clean the company name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-name/m-p/527583#M143848</link>
    <description>&lt;P&gt;dear all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I face&amp;nbsp;trouble when I clean the company name by using following&amp;nbsp;code to exclude the PLC. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;data Step3.Datastream_gb_export_2nd;
set Step5.Datastream_gb2;
call scan(COMPANY_NAME, -1, position, length);
if scan(COMPANY_NAME,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(COMPANY_NAME_1, -1, position, length);
if scan(COMPANY_NAME_1,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME_1,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(COMPANY_NAME___SHORT, -1, position, length);
if scan(COMPANY_NAME___SHORT,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME___SHORT,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(PREVIOUS_NAME, -1, position, length);
if scan(PREVIOUS_NAME,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(PREVIOUS_NAME,position)=' ';
drop position length;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I did not exclude all of them successfully. For example&amp;nbsp;'S.A.'&amp;nbsp; 'Corporation'.&amp;nbsp;I have added the source excel(&amp;nbsp;Step5.Datastream_gb2) and&amp;nbsp;result excel (Step3.Datastream_gb_export_2nd) in the attachments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Jan 2019 01:07:02 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2019-01-16T01:07:02Z</dc:date>
    <item>
      <title>clean the company name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-name/m-p/527583#M143848</link>
      <description>&lt;P&gt;dear all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I face&amp;nbsp;trouble when I clean the company name by using following&amp;nbsp;code to exclude the PLC. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-sas"&gt;data Step3.Datastream_gb_export_2nd;
set Step5.Datastream_gb2;
call scan(COMPANY_NAME, -1, position, length);
if scan(COMPANY_NAME,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(COMPANY_NAME_1, -1, position, length);
if scan(COMPANY_NAME_1,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME_1,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(COMPANY_NAME___SHORT, -1, position, length);
if scan(COMPANY_NAME___SHORT,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(COMPANY_NAME___SHORT,position)=' ';
drop position length;
run;
data Step3.Datastream_gb_export_2nd;
set Step3.Datastream_gb_export_2nd;
call scan(PREVIOUS_NAME, -1, position, length);
if scan(PREVIOUS_NAME,-1) in ('LTD' ,'LTD.' ,'LIMITED' ,'PLC' ,'PLC.' ,'AG' ,'S.A.' ,'SA' ,'corporation' ,'CORP.' 'CORP' ,'INC.' ,'INC' ,'COMPANY') then substr(PREVIOUS_NAME,position)=' ';
drop position length;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I did not exclude all of them successfully. For example&amp;nbsp;'S.A.'&amp;nbsp; 'Corporation'.&amp;nbsp;I have added the source excel(&amp;nbsp;Step5.Datastream_gb2) and&amp;nbsp;result excel (Step3.Datastream_gb_export_2nd) in the attachments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 01:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-name/m-p/527583#M143848</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2019-01-16T01:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: clean the company name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/clean-the-company-name/m-p/527595#M143857</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the scan function by default would see any of these as delimiters&amp;nbsp;&lt;STRONG&gt;blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ^ :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So the last "word" of&amp;nbsp;a string ending S.A. is not going to be S.A.&amp;nbsp; as that is 2 words.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try creating a new column in your dataset that contains the result of the scan function and you can see&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new=scan(COMPANY_NAME,-1)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You also have not specfied 'Corporation'&amp;nbsp; - but 'corporation' is there .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a look at using tranwrd/trantrn for this as it may save you some time .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 01:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/clean-the-company-name/m-p/527595#M143857</guid>
      <dc:creator>34reqrwe</dc:creator>
      <dc:date>2019-01-16T01:48:13Z</dc:date>
    </item>
  </channel>
</rss>

