Sample 51736: Perform a fuzzy merge using the SQL procedure and the SPEDIS function
The sample code on the Full Code tab uses the SPEDIS function with the SQL procedure to perform a fuzzy merge.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
The following code uses the SPEDIS function along with the SQL procedure to perform a fuzzy merge on two SAS data sets.
data one;
input business_name $1-23 zip :$ 31-39 city_st : $ 42-60 ;
datalines;
21st ABC 12345 Cleveland,OH
3d Solutions 56789 Cleveland,OH
3Degrees 101233 Cleveland,OH
Foods Corp. 145677 Cleveland,OH
A&B Machine, Inc. 190121 Cleveland,OH
Place for Family 234565 Cleveland,OH
A S I inc. 279005 Cleveland,OH
Rouben's Sales & Lease 323453 Cleveland,OH
XYZ Holding Co 367897 Cleveland,OH
XYZ Carpet 412341 Cleveland,OH
Able Energy, Inc. 456785 Cleveland,OH
Rouben Equipment Rental 501229 Cleveland,OH
Abrasive Technology,Inc 545673 Cleveland,OH
ZZZZ Lens 590117 Cleveland,OH
;
run;
proc print data=one;
run;
data two;
input business_id :$ business_name $5-32 business_addr :$ business_addr2 :$
business_city :$ business_state :$ business_zip :$;
datalines;
1 3d Solutions data data data data data
2 3d Solutions inc data data data data data
3 3d Solutions incorporated data data data data data
4 Foods Corp. data data data data data
5 A&B Machine data data data data data
6 Place for Family data data data data data
7 A S I inc data data data data data
8 Rouben's Sales & Lease data data data data data
9 XYZ Holding Co data data data data data
10 XYZ Carpet data data data data data
11 Able Energy., Inc. data data data data data
12 Rouben's Equipment Rental data data data data data
13 Abrasive Technology, Inc. data data data data data
14 ZZZZ Lens corp. data data data data data
15 RADIOLOGY ASSOCIATES data data data data data data
;
run;
proc print data=two;
run;
proc sql;
create table three as
select a.business_name as business_one, b.business_name as business_two from one a ,two b
where spedis(a.business_name, b.business_name) <= 50;
quit;
proc print data=three;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs business_one business_two
1 3d Solutions 3d Solutions
2 3d Solutions 3d Solutions inc
3 Foods Corp. Foods Corp.
4 A&B Machine, Inc. A&B Machine
5 Place for Family Place for Family
6 A S I inc. A S I inc
7 Rouben's Sales & Lease Rouben's Sales & Lease
8 XYZ Holding Co XYZ Holding Co
9 XYZ Carpet XYZ Carpet
10 Able Energy, Inc. Able Energy., Inc.
11 Able Energy, Inc. Abrasive Technology, Inc.
12 Rouben Equipment Rental Rouben's Equipment Rental
13 Abrasive Technology,Inc Abrasive Technology, Inc.
14 ZZZZ Lens ZZZZ Lens corp.
Date Modified: | 2013-12-20 15:21:42 |
Date Created: | 2013-12-03 18:23:04 |
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
Z64 | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 8 Enterprise 32-bit | | |
Microsoft Windows 8 Enterprise x64 | | |
Microsoft Windows 8 Pro 32-bit | | |
Microsoft Windows 8 Pro x64 | | |
Microsoft Windows 8.1 Enterprise 32-bit | | |
Microsoft Windows 8.1 Enterprise x64 | | |
Microsoft Windows 8.1 Pro | | |
Microsoft Windows 8.1 Pro 32-bit | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 R2 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows Server 2012 Datacenter | | |
Microsoft Windows Server 2012 R2 Datacenter | | |
Microsoft Windows Server 2012 R2 Std | | |
Microsoft Windows Server 2012 Std | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |