Date: Thu, 10 Jul 2008 18:13:32 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: detecting variations in name using SAS
Nikhil,
As long as the file doesn't have TOO many records, and you can manually
decide what the correct names should be, then you could do something like
the following using proc format:
data have;
input Name $80.;
cards;
IBM
IBM
IBM
IBM corp
IBM corp
international business machines
Microsoft
Microsoft
Microsoft
Microsoft
Mocrosft corp
Micro soft
yahoo
yahoo
yahoo
yahoo!
yahoo!
yahoo!
yahoo!
YAHOO
YAHOO
YAHOO
YAHOO
;
proc sort data=have nodupkey out = unique;
by name;
run;
proc print data=unique;
run;
* Create desired names for each unique name;
data shouldbe;
input LABEL $80.;
cards;
IBM
IBM
Microsoft
Microsoft
Microsoft
YAHOO
IBM
YAHOO
YAHOO
;
* prep for proc format;
data both;
set unique (rename=(name=START));
set shouldbe;
FMTNAME='$namefmt';
END=START;
run;
* build format from file ;
proc format cntlin=both;
run;
* apply format;
data want;
set have;
name = put(name,$namefmt.);
run;
HTH,
Art
---------
On Thu, 10 Jul 2008 06:11:49 -0700, n <nikhil.abhyankar@GMAIL.COM> wrote:
>I have a dataset containing the names of some companies.
>eg ,
> Name X
>IBM 1
>IBM corp 1
>international business machines 1
>Microsoft 2
>Mocrosft corp 2
>Micro soft 2
>yahoo 3
>yahoo! 3
>YAHOO 3
>
>I need to use SAS and prepare a list of unique company names. The
>solution has to have a way to detect variations in the names,
>including spelling mistakes.
> The output expected is something like,
>
>Name X
>IBM 3
>Microsoft 6
>Yahoo 9
>
>Please, tell how I could do it using SAS.