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).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.