BookmarkSubscribeRSS Feed
sasmaverick
Obsidian | Level 7

data test;

set varin;

found=findw('Art festival.','art','','it');

put found=;

run;

The above code is returning the value of found as 0. Anybody knows why? Even though I am ignoring case and removing trailing blanks from the arguments. If I remove the 't' modifier, the value is returned correctly as 1. If I use STRIP function on the second argument, the value is again returned correctly.

Thanks for the help.

2 REPLIES 2
Tom
Super User Tom
Super User

Probably because it ends up trimming the space out of the list of delimiter characters.  Add 'S' to the modifiers.  Or add other characters such as period and comma to the list of delimiter characters..  Also making the list of delimiters a variable instead of an in-line character constant seems to also make it work.

Patrick
Opal | Level 21

It says in the the docu:

t or T trims trailing blanks from the string, word, and character arguments.

So it appears trimming the character argument removes blanks from the list of word delimiters. Initially not really intuitive to me but then with a bit more thinking isn't this exactly what I would expect to happen if passing in a variable as character argument? So using the 't' switch with an explicit string as character argument is definitely not the right thing to do.

data _null_;

  found1=findw('Art festival.','art',' ','it');

  found2=findw('Art festival.','art','','i');

  found3=findw('Art|festival.','art','|','it');

  put _all_;

  stop;

run;

found1=0 found2=1 found3=1

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2863 views
  • 0 likes
  • 3 in conversation