DATA Step, Macro, Functions and more

Exact text match using Find

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

Exact text match using Find

Hi,

I need to find an exact match of a text.

From the list below, I need to flag records (1 & 2) with the text "Connect". But when I use Find() it flags all the 4 records. Findw() is not helping either.

Connect

Service, Connect

Service, Connect/Boat

Service, Connect/Friend

Thanks!


Accepted Solutions
Solution
‎03-23-2015 08:39 PM
Respected Advisor
Posts: 3,124

Re: Exact text match using Find

Findw should work for you in this case, you just need to specify the delimiters, otherwise the default will kick in, which includes '/' that you don't want.

data test;

     infile cards truncover;

     input str $ 20.;

     flag=findw(str,'Connect', ' ,')>0;

     cards;

Connect

Service, Connect

Service, Connect/Boat

Service, Connect/Friend

;

View solution in original post


All Replies
Solution
‎03-23-2015 08:39 PM
Respected Advisor
Posts: 3,124

Re: Exact text match using Find

Findw should work for you in this case, you just need to specify the delimiters, otherwise the default will kick in, which includes '/' that you don't want.

data test;

     infile cards truncover;

     input str $ 20.;

     flag=findw(str,'Connect', ' ,')>0;

     cards;

Connect

Service, Connect

Service, Connect/Boat

Service, Connect/Friend

;

Contributor
Posts: 34

Re: Exact text match using Find

Thank you!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 219 views
  • 0 likes
  • 2 in conversation