DATA Step, Macro, Functions and more

merge with case insensitive

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

merge with case insensitive

Hi, Do we have any option that can be used in merge statement to match result without checking if value is in lower or upper case. ex:- Bob in one dataset (test1) should match with bob (test2) in another dataset without making any chnage in original dataset (upcase or lowercase).

 

Data test;

merge test1 test2;

by name;

run;

 

We can change to upper or lower case in test1 and test2 by upcase or lowercase but just want to know if there is any oprtion can be used that ignore case sensitive while match merge.

 

Thanks


Accepted Solutions
Solution
‎04-05-2016 10:39 AM
Super User
Posts: 5,424

Re: merge with case insensitive

Sorry, to my knowledge there is nothing in SAS that corresponds to case insensitive matching found in other databases. You need to upper/lowercase your data prior to the merge.
If you would use SQL instead you could do in the same step in the where/on statement.
Data never sleeps

View solution in original post


All Replies
Solution
‎04-05-2016 10:39 AM
Super User
Posts: 5,424

Re: merge with case insensitive

Sorry, to my knowledge there is nothing in SAS that corresponds to case insensitive matching found in other databases. You need to upper/lowercase your data prior to the merge.
If you would use SQL instead you could do in the same step in the where/on statement.
Data never sleeps
Super User
Super User
Posts: 7,942

Re: merge with case insensitive

Not directly, you can do it in SQL:

proc sql;
  create table TEST as
  select  A.NAME as TEST1,
          B.NAME as TEST2
  from    TEST1 A
  full join TEST2 B
  on       upcase(A.NAME)=upcase(B.NAME);
quit;

Otrherwise, yes, create an upcase or lowcase of each and merge by that.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 1614 views
  • 1 like
  • 3 in conversation