Hi dear all.
I have a basic function and I can't find what i'm looking for...
the below code works:
data have;
re="all";
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all , people';
if indexw(texto,ra)>0 then do;
bi="wee";
end;
run;
and this one not ... ( because there is a comma after 'all' in texto:
data have;
re="all";
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';
if indexw(texto,ra)>0 then do;
bi="wee";
end;
run;
how to fix that, to make the index or indexw find the word even if there is a comma, period etc after or before the searched word ( or series of words' like ro re... ?
Thanks for the response.
Sincerely.
Hi,
You can use Trim function.
data have;
re="all";
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';
if index(texto,(trim(ra)))>0 then do;
bi="wee";
end;
run;
Regards,
Anushree
Hi,
You can use Trim function.
data have;
re="all";
ro="hello";
ra=catx('',ro,re);
texto='blablabla hello all, people';
if index(texto,(trim(ra)))>0 then do;
bi="wee";
end;
run;
Regards,
Anushree
In your second code of texto attribute of value, space is removed after "ALL".
Thats why you are not getting result.
as per First code, Space is there after ALL.
add space and then run.
The mentioned solution is working, I've also used strip and it worked too...
thanx 🙂
INDEXW has an options parameter to contain delimiters. The default delimiter is blank.
Add additional delimiters as a string literal or variable containing desired delimiters after the search string.
Note that you do want to include a blank or that would stop being a delimiter.
if indexw(texto,ra, " ,.!?/()&%" )>0 then do
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!
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.