BookmarkSubscribeRSS Feed
France
Quartz | Level 8

Dear all,

 

I would like to replace “LIMITED” with “LTD”, “SOCIETE ANONYME” with “SA”. 

 

NAME
DYNAMIC COMMERCIAL FINANCE PLC,
MTR CORPORATION LIMITED,
INTERCEDE GROUP SOCIETE ANONYME

as 

NAME
DYNAMIC COMMERCIAL FINANCE PLC,
MTR CORPORATION LTD,
INTERCEDE GROUP SA

 

could you please give me some suggestion about it? 

thanks in advance

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Tranwrd:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000215027.htm

 

Perl regular expressions.  Findw/substr.  Other string functions.

France
Quartz | Level 8

Dear RW9,

 

thank you for your advice. 

 

I have tried to use,

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;

However,  I did not get the variable. Could you please give some suggestions in detail.

 

thanks in advance.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its really not possible to answer from "However,  I did not get the variable. ".  What didn't happen?  Post test data in the form of a datastep - this is so we can see what your working with.  The code:

data temp;
  company_name="Somewhere LIMITED company";
  name1=tranwrd(company_name,"LIMITED","LTD");
  name1=tranwrd(name1,"SOCIETE ANONYME","SA");
run;

Works fine.  Note that the second tranwrd should use the name1 variable and from there on in.

Reeza
Super User
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.
France
Quartz | Level 8
Dear Reeza,

thanks for your kind advice.

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.
Reeza
Super User

@France wrote:
Dear Reeza,

thanks for your kind advice.

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.

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. 

error_prone
Barite | Level 11
What do you expect as result of name is
Limited Luxurious Lending Incorporated
?

It is hardly possible - at least not without a larger amount of code - to produce the expected result.
France
Quartz | Level 8
Dear error_prone,

thanks for your helpful advice.

is there any method I can use to only replace the last 'LIMITED' as 'LTD'.
mansour_ib_sas
Pyrite | Level 9

Hello,

I make this solution with macro 

 

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(&var_have), &i, %str(,)))>0);
subject=tranwrd(subject, scan("&var_have",&i, ',') , scan("&var_change",&i, ',' ) );

%let i=%eval(&i+1);
%end;
run;
%mend test;

%test;







sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1059 views
  • 0 likes
  • 5 in conversation