I would like to identify a dummy variable where 1= the company names that contain the words “America(n)” or “US(A)” and 0= otherwise. Please see a sample below:
Thank you very much
HAVE
FIRM_ID NAME
1 AMERICAN MOBILE SYS
2 GAS NATURAL INC
3 UNIVERSAL AMERICAN CORP
4 CRUISE AMERICA INC
5 TELECOM USA INC
6 GENERAL MOTORS CO
7 US AIRWAYS GROUP INC
8 HOME STAKE MINING
WANT
FIRM_ID NAME DUMMY
1 AMERICAN MOBILE SYS 1
2 GAS NATURAL INC 0
3 UNIVERSAL AMERICAN CORP 1
4 CRUISE AMERICA INC 1
5 TELECOM USA INC 1
6 GENERAL MOTORS CO 0
7 US AIRWAYS GROUP INC 1
8 HOME STAKE MINING 0
dummy =
indexw(upcase(name),'AMERICA') or
indexw(upcase(name),'AMERICAN') or
indexw(upcase(name), 'US') or
indexw(upcase(name),'USA')
;
Try it on your own, and if you run into problems, post the log (use the {i} button for posting logs).
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.