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-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
  • 656 views
  • 1 like
  • 3 in conversation