BookmarkSubscribeRSS Feed
mattneo
Obsidian | Level 7

I have thousand of rows of subject titles. I want to sieve out subject titles based on what I entered in a search parameter. Therefore I have an advanced filter like this in a list table:

 

Upcase (subject title) contains Upcase (search parameter)

 

So if I entered "cat" in the text input box (embed with a search parameter), the list table should show all subject titles contain "cat". BUT, here's the problem: I don't want words that contains "cat" in their spelling, like "application" or "allocation", to be part of the results. I only want those that literally have the word "cat" in the subject titles.

 

Please help. Thank you.

6 REPLIES 6
ed_sas_member
Meteorite | Level 14

Hi @mattneo 

 

You can use either one of the following functions:

 

 

data want;
	set have;
	where findw(subject_title,"cat"," ","i"); /* i modifier specifies that the search is case insensitive*/
run;

or

 

data want;
	set have;
	where prxmatch('/\bcat\b/i',subject_title); /* i modifier specifies that the search is case insensitive and the meta character \b looks for a word boundary*/
run;

Best,

 

 

mattneo
Obsidian | Level 7

Hi @ed_sas_member 

 

Thanks for the reply. However, I presumed these are codes to be applied some place? Sorry, I forgot to mention I am using SAS VA 8.3 and have the access to build reports and dashboards. 

 

Not sure if it's possible to copy and paste the below codes to the text portion in Advanced Filter to make it work. But I don't remember seeing operators like "findw" in it. Any ideas on how to meet my needs with the Operators in SAS VA? I was thinking to apply the following in Advanced Filter:

 

UpCase( GetWord( Subject_title, Search Parameter, x) Contains Upcase( Search parameter)   ,

where Search parameter = "cat" here

x is a number for the location to find the word "cat" within the subject title.

 

The thing is x can be any number for different subject titles. Hence I am stuck again.

 

Any help and ideas will be appreciated. Cheers.

ed_sas_member
Meteorite | Level 14
Hi @mattneo,
Thank you for your reply.
Unfortunatly, I am not familiar with SA VA 😞
Hope you fill find the solution.
Best,
FredrikE
Rhodochrosite | Level 12

Hi!

I tried to add ' ' (space) before and after my search parameter. I also added logic for missing search Parameter and think it works, is that what you want?

 

Parameter name: 'searchPar'p

Variable name: myStringVar

 

IF ( 'searchPar'p Missing )
RETURN ( 1 = 1 )
ELSE ( UpCase('myStringVar'n) Contains UpCase(Concatenate(Concatenate(' ', 'searchPar'p), ' ')) )

 

//Fredrik

mattneo
Obsidian | Level 7
Thanks Fredrik. The expression makes sense. Will let u know if there are any issues. Cheers,
mattneo
Obsidian | Level 7
The expression works if parameter is in the middle of the title. For example, if parameter= "cat", then title like " Some cat issues" appears. But what if "cat" appears at the start or end of title, like "Cat issues...." or "My pet cat", where there are no spaces at the start or at the end?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1352 views
  • 1 like
  • 3 in conversation