As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tips:I want to hear the sound of SOUNDEX"

From sasCommunity
Jump to: navigation, search
(gardening)
(gardening)
 
Line 2: Line 2:
  
 
<source lang="sas">
 
<source lang="sas">
/*EXAMPLE OF SOUNDEX PHONETIC APPLICATION*/
+
/* Example of soundex phonetic application */
  
DATA _NULL_;
+
data _null_;
  
/*A CASE WHERE THE NAME IS THE SAME BUT SPELT DIFFERENTLY*/
+
    /* a case where the name is the same but spelt differently */
  
NAME1 = "IAN";
+
    name1 = "ian";
NAME2 = "IAIN";
+
    name2 = "iain";
  
/*A DIRECT STRING COMPARISON IN THIS CASE WILL FAIL*/
+
    /* a direct string comparison in this case will fail */
  
IF NAME1 = NAME2 THEN PUT "NAME1 = NAME2 IS TRUE.";
+
    if name1 = name2 then put "name1 = name2 is true.";
ELSE PUT "NAME1 = NAME2 IS FALSE.";
+
    else put "name1 = name2 is false.";
  
/*A SOUNDEX STRING COMPARISON IN THIS CASE WILL SUCCEED*/
+
    /* a soundex string comparison in this case will succeed */
  
IF SOUNDEX(NAME1) = SOUNDEX(NAME2) THEN PUT "NAME1 = NAME2 IS TRUE.";
+
    if soundex(name1) = soundex(name2) then put "name1 = name2 is true with soundex.";
ELSE PUT "NAME1 = NAME2 IS FALSE.";
+
    else put "name1 = name2 is false with soundex.";
  
RUN;
+
run;
 
</source>
 
</source>
  
 
{{SubmittedBy|Goladin|Murphy Choy}}
 
{{SubmittedBy|Goladin|Murphy Choy}}
 
  
 
<noinclude>
 
<noinclude>
 
[[Category:Tip in Use]]
 
[[Category:Tip in Use]]
 
[[Category:Functions and CALL Routines]]
 
[[Category:Functions and CALL Routines]]
[[category:Statements]]
+
[[Category:Statements]]
 
</noinclude>
 
</noinclude>

Latest revision as of 13:13, 8 September 2017

Phonetic algorithms can be useful in situation where the names are spelled differently by the same person. In this situation, it is critical that phonetic algorithms are used for de-duplication purposes. See the Wikipedia article on Soundex.

/* Example of soundex phonetic application */
 
data _null_;
 
    /* a case where the name is the same but spelt differently */
 
    name1 = "ian";
    name2 = "iain";
 
    /* a direct string comparison in this case will fail */
 
    if name1 = name2 then put "name1 = name2 is true.";
    else put "name1 = name2 is false.";
 
    /* a soundex string comparison in this case will succeed */
 
    if soundex(name1) = soundex(name2) then put "name1 = name2 is true with soundex.";
    else put "name1 = name2 is false with soundex.";
 
run;

Submitted by Murphy Choy. Contact me at my Discussion Page.