Help using Base SAS procedures

sounds like function

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

sounds like function

Hi I have a variable in a dataset and want to check if a word sounds like

I used the following and did not work for me..

Could you please correct??

Thanks

data want;

set have;

if description like "myocar" then flg=1;

run;


Accepted Solutions
Solution
‎05-20-2013 05:17 PM
Respected Advisor
Posts: 3,124

Re: sounds like function

Statring with "myocar" and Sounds like it are completely different concept, considering the scenario like this:

mmyocar vs myocar, NOT Starting, but very much Sound like;

while: myocarapdofhaposdjf vs myocar, nah.

data test;

  a='myocaringhongtingdon';

  output;

  a='mmyocar';

  output;

run;

data _null_;

set test;

if soundex(a)=soundex('myocar') then put a "Sound like";

else put a "NOT sound like";

run;

You need to be clear on what you are really after, then choose the right tools. Soundex works based on English pronunciation,  if it does not meet your need, look for other options like spedis, complev, compare, compged.

View solution in original post


All Replies
Respected Advisor
Posts: 3,124

Re: sounds like function

Proc SQL =* operator.

Proc sql;

  create table want as

     select *, case when description =*  "myocar" then 1 else 0 end as flg

        from have;

quit;

Haikuo

Super Contributor
Posts: 1,040

Re: sounds like function

Hi Thanks. Is there any Datastep option to do the same??

Thanks

Respected Advisor
Posts: 3,124

Re: sounds like function

Sure, if you insist:

data want;

  set have;

   if soundex(description)=soundex('myocar') then flg=1;

run;

Haikuo

Super Contributor
Posts: 1,040

Re: sounds like function

Hi ,

I still keep getting all missing values in the flg variable even though there are words starting with myocar

Where could i have gone wrong???

Solution
‎05-20-2013 05:17 PM
Respected Advisor
Posts: 3,124

Re: sounds like function

Statring with "myocar" and Sounds like it are completely different concept, considering the scenario like this:

mmyocar vs myocar, NOT Starting, but very much Sound like;

while: myocarapdofhaposdjf vs myocar, nah.

data test;

  a='myocaringhongtingdon';

  output;

  a='mmyocar';

  output;

run;

data _null_;

set test;

if soundex(a)=soundex('myocar') then put a "Sound like";

else put a "NOT sound like";

run;

You need to be clear on what you are really after, then choose the right tools. Soundex works based on English pronunciation,  if it does not meet your need, look for other options like spedis, complev, compare, compged.

Super Contributor
Posts: 1,040

Re: sounds like function

Thanks for the detailed explanation. I appreciate your help.

Thanks...

🔒 This topic is solved and locked.

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

Discussion stats
  • 6 replies
  • 277 views
  • 0 likes
  • 2 in conversation