Hello everyone!
I have this dataset with me:
Executive_Name Executive_Role New_Variable
Arnold president & CEO 0
Tracy executive vp & chief operating officer 0
Victor vp & chief finance officer 1
Hunter vp, general counsel & secretary 0
Joseph Chief Financial Officer and Senior Vice President 1
I am trying to come up with a new_variable taking the value 1 if the column relating to the executive roles contains the words either 'finance' or 'financial', and 0 otherwise. Can you please help in this regard?
Regards,
Aman
data have;
input Executive_Name$ Executive_Role&$128. ;
cards;
Arnold president & CEO
Tracy executive vp & chief operating officer
Victor vp & chief finance officer
Hunter vp, general counsel & secretary
Joseph Chief Financial Officer and Senior Vice President
;
run;
data want;
set have;
if find(Executive_Role,'finance','i') or find(Executive_Role,'financial','i') then new_variable=1;
else new_variable=0;
run;
data have;
input Executive_Name$ Executive_Role&$128. ;
cards;
Arnold president & CEO
Tracy executive vp & chief operating officer
Victor vp & chief finance officer
Hunter vp, general counsel & secretary
Joseph Chief Financial Officer and Senior Vice President
;
run;
data want;
set have;
if find(Executive_Role,'finance','i') or find(Executive_Role,'financial','i') then new_variable=1;
else new_variable=0;
run;
Do you have just the two words, or are there maybe more for other flags?
Thank you fr your response!
No, I had only two words.
Regards,
Amanjot
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.