Dear @ChrisNZ
I think your code works well. However, 1, I worry about the presence of ' ' and " " following 'COMPANY'
for example
data T;
input NAME_S22 :&$200.;
cards;
3M COMPANY (MINNESOTA MINING AND MANUFACTURING COMPANY)
3M COMPANY 'MINNESOTA MINING AND MANUFACTURING COMPANY'
3M COMPANY "MINNESOTA MINING AND MANUFACTURING COMPANY"
run;
I expect to get
NAME_S22 | NAME_B |
3M COMPANY (MINNESOTA MINING AND MANUFACTURING COMPANY) | 3M CO (MINNESOTA MINING AND MANUFACTURING COMPANY) |
3M COMPANY 'MINNESOTA MINING AND MANUFACTURING COMPANY' | 3M CO 'MINNESOTA MINING AND MANUFACTURING COMPANY' |
3M COMPANY "MINNESOTA MINING AND MANUFACTURING COMPANY" | 3M CO "MINNESOTA MINING AND MANUFACTURING COMPANY" |
I expect to use (\'[^']*\')* and (\"[^']*\")* based on the code which you taught me(i.e., (\([^)]*\))*). However it out of work in the regex in SAS.
2.Besides,
For the value 'ARCH TIMBER PROTECTION LIMITED, A PRIVATE LIMITED COMPANY ORGANISED UNDER THE LAWS OF THE UNITED KINDGOM' I expect to get the value of 'NAME_B' which stopping the process when meeting the first company suffix.
NAME | name_B | name_address |
ARCH TIMBER PROTECTION LTD A PRIVATE LTD CO ORGANISED UNDER THE LAWS OF THE UNITED KINDGOM | ARCH TIMBER PROTECTION LTD | A PRIVATE LTD CO ORGANISED UNDER THE LAWS OF THE UNITED KINDGOM |
Could you please give me some suggestion about these two questions?
@Alexxxxxxx What have you learnt?
data WANT;
set HAVE;
NAME1=prxchange('s/( ?,?L ?\.? ?T ?\.? ?D ?\.? ?,?)/ LTD /' ,1,NAME );
NAME2=prxchange('s/( ?,?C ?\.? ?O ?\.? ?,?)/ CO /' ,1,NAME1);
NAME3=prxchange('s/(.*)( CO LTD | LTD CO | LTD | CO )(.*)/$1$2/',1,NAME2);
NAME4=prxchange('s/(.*)( CO LTD | LTD CO | LTD | CO ) *(.*)/$3/',1,NAME2);
run;
NAME3 | NAME4 |
---|---|
AAA LTD | NEW YORK |
AAA LTD | NEW YORK |
AAA LTD | LONDON |
AAA LTD CO | TOKYO |
AAA CO LTD | TOKYO |
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.