BookmarkSubscribeRSS Feed
msd83
Calcite | Level 5

Hi all,

Thanks for taking time to help me.

I have two datasets which I want to merge on people's surname.

In one dataset the field contains just the surname but in the other dataset the field contains other words (potentially before or after the surname).

Is there any way to join the two datasets?

E.g. Surname (table 1)        Name (table 2)


          Smith                        Mr.Tom Smith     


I would want to join the records for this example above.


I have tried using proc sql, create table ... with a where clause with the contains function but that did not work.

I have SAS 9.4.

Any help will be much appreciated.

3 REPLIES 3
stat_sas
Ammonite | Level 13

proc sql;

select * from table1,table2

where table2.name contains strip(table1.surname);

quit;

Peter_C
Rhodochrosite | Level 12

stat@sas wrote:

proc sql;

select * from table1,table2

where upcase( table2.surname ) contains upcase( strip(table1.surname) ) ;

quit;

with a little update in case SurName is not reliably in a consistent case

good luck

msd83
Calcite | Level 5

Thank you both for your help, that is great. Smiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 870 views
  • 6 likes
  • 3 in conversation