BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amanjot_42
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
whymath
Lapis Lazuli | Level 10
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;

View solution in original post

4 REPLIES 4
whymath
Lapis Lazuli | Level 10
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;
amanjot_42
Fluorite | Level 6
Thank you very much!
It worked really well!
Regards,
Aman
andreas_lds
Jade | Level 19

Do you have just the two words, or are there maybe more for other flags?

amanjot_42
Fluorite | Level 6

Thank you fr your response!

No, I had only two words.

Regards,

Amanjot

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
  • 4 replies
  • 565 views
  • 1 like
  • 3 in conversation