BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shradha1
Obsidian | Level 7
I have a column on first names and another on email ids. How do I check if email id contains the first name? I am Working on sas 9.4. I have used the FIND function but it returns 0 for all observations
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

You need to use trim around the second parameter of find, like

containsFirstname = find(eMail, trim(firstname)) > 0;

View solution in original post

4 REPLIES 4
PhilC
Rhodochrosite | Level 12

Have you changed the case of your strings?  Using UPCASE() or LOWCASE() helps for this.  One would apply one of these function to both strings before using FIND().

Shradha1
Obsidian | Level 7
Yes. Both the strings are in upper case, still the find function is giving the value as 0 for all observations, which shouldn't be the case, because there are many email IDs with first name present in them
andreas_lds
Jade | Level 19

You need to use trim around the second parameter of find, like

containsFirstname = find(eMail, trim(firstname)) > 0;
Shradha1
Obsidian | Level 7
This worked. Thanks a lot!!

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1258 views
  • 1 like
  • 3 in conversation