Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Searching for multiple character strings within a var

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Searching for multiple character strings within a var

Hello,

I am working on an automotive client digging through their service data, and all they have provided is VIN level information with a single variable containing all work done on that Repair Order.  I am searching for Brake Replacements, but this variable is free text for the service tech to write in whatever he or she would like.

So I have 17.2 M records, of which I need to search for about 20 iterations, "Front Brake Pad" or "Rear Brake" or "Turn Rotor" or the like.  I have these set up in a %LET statement.

ex:

%LET Brakes = 'REPLACE FRONT BRAKE','REPLACE REAR BRAKE','TURN ROTOR','SURFACE BRAKE DRUM','MACHINE BRAKE ROTORS' ... ;

IF INDEXW(Description,&Brakes.) > 0;

INDEX only searches for one string

INDEXC  only will search for the first character in the string

INDEXW and FINDW says my string contains too many arguments

Can anyone suggest how I can look at this, please?

Thank you!


Accepted Solutions
Solution
‎01-22-2013 01:35 PM
Super Contributor
Posts: 543

Re: Searching for multiple character strings within a var

Posted in reply to That____Redhead

Hi.

How about this?

data want;

    set your_data;

    IF prxmatch('m/brake/oi', your_var) > 0;

run;

OR

data want;

    set your_data;

     *also keep the record that has 'turn rotor', or 'surface drum', or....(which you tell SAS by using the | delimiter);

    IF prxmatch('m/brake|turn rotor| surface drum/oi', your_var) > 0;

run;

Good luck!

Anca.

View solution in original post


All Replies
Solution
‎01-22-2013 01:35 PM
Super Contributor
Posts: 543

Re: Searching for multiple character strings within a var

Posted in reply to That____Redhead

Hi.

How about this?

data want;

    set your_data;

    IF prxmatch('m/brake/oi', your_var) > 0;

run;

OR

data want;

    set your_data;

     *also keep the record that has 'turn rotor', or 'surface drum', or....(which you tell SAS by using the | delimiter);

    IF prxmatch('m/brake|turn rotor| surface drum/oi', your_var) > 0;

run;

Good luck!

Anca.

Contributor
Posts: 25

Re: Searching for multiple character strings within a var

Posted in reply to AncaTilea

Thanks Anca,

I'm still getting the space error - I have 18 text strings I am searching for, and it's about 350 characters long.  I'll just use this and shorten it into two PRXMATCH functions.

Thanks!         

🔒 This topic is solved and locked.

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

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