BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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

6 REPLIES 6
Haikuo
Onyx | Level 15

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

robertrao
Quartz | Level 8

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

Thanks

Haikuo
Onyx | Level 15

Sure, if you insist:

data want;

  set have;

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

run;

Haikuo

robertrao
Quartz | Level 8

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???

Haikuo
Onyx | Level 15

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.

robertrao
Quartz | Level 8

Thanks for the detailed explanation. I appreciate your help.

Thanks...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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