<?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: replace part of variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514824#M138857</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I make this solution with macro&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option symbolgen mprint mlogic;

DATA test;
infile cards dsd truncover;
INPUT subject $100.  ;
CARDS;
NAME
DYNAMIC COMMERCIAL FINANCE PLC 
MTR CORPORATION LIMITED
INTERCEDE GROUP SOCIETE ANONYME
;
run;

%let var_have =LIMITED,SOCIETE ANONYME ;
%let var_change=LTD ,SA ;



%macro test();
data test;
set test;
%let i=1;
%do %while(%length(%scan(%quote(&amp;amp;var_have), &amp;amp;i, %str(,)))&amp;gt;0);
subject=tranwrd(subject, scan("&amp;amp;var_have",&amp;amp;i, ',') , scan("&amp;amp;var_change",&amp;amp;i, ',' ) );

%let i=%eval(&amp;amp;i+1);
%end;
run;
%mend test;

%test;







&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Nov 2018 16:31:14 GMT</pubDate>
    <dc:creator>mansour_ib_sas</dc:creator>
    <dc:date>2018-11-20T16:31:14Z</dc:date>
    <item>
      <title>replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514746#M138817</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to replace “LIMITED” with “LTD”, “SOCIETE ANONYME” with “SA”.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NAME
DYNAMIC COMMERCIAL FINANCE PLC,
MTR CORPORATION &lt;U&gt;LIMITED&lt;/U&gt;,
INTERCEDE GROUP &lt;SPAN&gt;SOCIETE ANONYME&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;as&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NAME
DYNAMIC COMMERCIAL FINANCE PLC,
MTR CORPORATION &lt;U&gt;LTD&lt;/U&gt;,
INTERCEDE GROUP &lt;U&gt;SA&lt;/U&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me some suggestion about it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514746#M138817</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-20T13:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514747#M138818</link>
      <description>&lt;P&gt;Tranwrd:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000215027.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000215027.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perl regular expressions.&amp;nbsp; Findw/substr.&amp;nbsp; Other string functions.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 13:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514747#M138818</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-20T13:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514781#M138840</link>
      <description>If your data set has an identifier for companies (BN, ID) use that instead. It's almost impossible to get the fuzzy matching for business names cleanly.</description>
      <pubDate>Tue, 20 Nov 2018 15:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514781#M138840</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-20T15:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514792#M138843</link>
      <description>What do you expect as result of name is&lt;BR /&gt;Limited Luxurious Lending Incorporated&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;It is hardly possible - at least not without a larger amount of code - to produce the expected result.</description>
      <pubDate>Tue, 20 Nov 2018 15:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514792#M138843</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-11-20T15:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514794#M138844</link>
      <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your advice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to use,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sa_step3.Data_UK_companies_try1;
set sa_step3.Datastream_UK_public_companies;
NAME1=tranwrd(COMPANY_NAME, "LIMITED", "LTD");
NAME1=tranwrd(COMPANY_NAME, "SOCIETE ANONYME", "SA");
put NAME1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However,&amp;nbsp; I did not get the variable. Could you please give some suggestions in detail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 15:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514794#M138844</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-20T15:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514797#M138845</link>
      <description>Dear Reeza,&lt;BR /&gt;&lt;BR /&gt;thanks for your kind advice.&lt;BR /&gt;&lt;BR /&gt;what I am doing is to match two databases by the companies' name (PATSTAT database and Datastream database). I did not find any identifier for both of them yet. so I have to standardise the companies' name and match them together. is there any method I can use to match successfully.</description>
      <pubDate>Tue, 20 Nov 2018 15:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514797#M138845</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-20T15:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514802#M138846</link>
      <description>&lt;P&gt;Its really not possible to answer from "&lt;SPAN&gt;However,&amp;nbsp; I did not get the variable.&amp;nbsp;".&amp;nbsp; What didn't happen?&amp;nbsp; Post test data in the form of a datastep - this is so we can see what your working with.&amp;nbsp; The code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data temp;
  company_name="Somewhere LIMITED company";
  name1=tranwrd(company_name,"LIMITED","LTD");
  name1=tranwrd(name1,"SOCIETE ANONYME","SA");
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Works fine.&amp;nbsp; Note that the second tranwrd should use the name1 variable and from there on in.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 16:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514802#M138846</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-20T16:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514809#M138848</link>
      <description>Dear error_prone,&lt;BR /&gt;&lt;BR /&gt;thanks for your helpful advice.&lt;BR /&gt;&lt;BR /&gt;is there any method I can use to only replace the last 'LIMITED' as 'LTD'.</description>
      <pubDate>Tue, 20 Nov 2018 16:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514809#M138848</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-11-20T16:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514812#M138849</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Dear Reeza,&lt;BR /&gt;&lt;BR /&gt;thanks for your kind advice.&lt;BR /&gt;&lt;BR /&gt;what I am doing is to match two databases by the companies' name (PATSTAT database and Datastream database). I did not find any identifier for both of them yet.&lt;STRONG&gt; so I have to standardise the companies' name and match them together. is there any method I can use to match successfully.&lt;/STRONG&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not really. I tried this last year and the best we could do was about 60% and that was after cleaning up all the LTD, CO and such. Company names are ugly and convoluted and they have too many subsidiaries with similar names to be reliable when matched.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 16:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514812#M138849</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-20T16:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: replace part of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514824#M138857</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I make this solution with macro&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option symbolgen mprint mlogic;

DATA test;
infile cards dsd truncover;
INPUT subject $100.  ;
CARDS;
NAME
DYNAMIC COMMERCIAL FINANCE PLC 
MTR CORPORATION LIMITED
INTERCEDE GROUP SOCIETE ANONYME
;
run;

%let var_have =LIMITED,SOCIETE ANONYME ;
%let var_change=LTD ,SA ;



%macro test();
data test;
set test;
%let i=1;
%do %while(%length(%scan(%quote(&amp;amp;var_have), &amp;amp;i, %str(,)))&amp;gt;0);
subject=tranwrd(subject, scan("&amp;amp;var_have",&amp;amp;i, ',') , scan("&amp;amp;var_change",&amp;amp;i, ',' ) );

%let i=%eval(&amp;amp;i+1);
%end;
run;
%mend test;

%test;







&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 16:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-part-of-variable/m-p/514824#M138857</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2018-11-20T16:31:14Z</dc:date>
    </item>
  </channel>
</rss>

