Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Variable for text string

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi all,

Need a little bit of help.

In my dataset i have a variable called comments, i want to search that variable for a specific text string.

I've done the below

Code:
if index(Concat_Comments, "1091") then
Error = "Y";
Else
Error = "N";

But the only problem is its bringing back customers telepohne numbers (if it contains 1091).

Is there any way to exclude those? e.g only flag it if there are no trailing or preceding numbers?

Ta

Robbie
 
I would take the resulting data and do further filtering on that and filter based on "-1091" or " 1091 "


You should be able to shrink your resulting file down to the pieces that you desire with multiple filter criteria.
 
shenniko, what version of SAS you using? If SAS 9 then you can make use the new Perl regular expression engine.

Code:
if PRXPARSE("/1091/") > 0 then Error="y";
else Error="n";

PRXPARSE will return the position of an exact match only. You could expand on this slightly and put something like:

Code:
PRXPARSE("/ (\d\d\d\d)+(1091) +/")

This would tell the engine it's looking for 4 numeric characters only and they must match 1091.

Cheers

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top