BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
There are two tables.Price dataset and Product dataset.
Recently I came across an issue where the product name in the price list has minor variation from the same product name in product dataset.This is causing drop in sales.

for instance:
price dataset has product name as CANDOR LEVODOPA 10MG.
product dataset has product name as CANDOR LEVODOPA 10MG.

not only that misspelling CANDOR LEVIDOPA 10MG.

How to compare character by character and identify where there is difference?
2 REPLIES 2
ChendhilKumar
Calcite | Level 5
Hi,

You have to do some data cleansing manually.
However, I would suggest you to try sounds-like operator to compare product_name variables in two tables. Refer to:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473716.htm

I have tried a sample code to test this.
/* -------------------------------------------------------------------------------- */
data price;
product_name='CANDOR LEVODOPA 10MG';
run;

data product;
product_name='CANDOR LEVIDOPA 10MG';
run;

proc sql;
/* The following sql won't return any row when using 'equal to i.e. =' operator in where clause */
create table compare_price_product_eq as
select pri.product_name as pri_product_name, pro.product_name as pro_product_name
from price pri, product pro
where pri.product_name = pro.product_name;

/* The following sql will return a row when using 'sound like i.e. =*' operator in where clause */
create table compare_price_product_sl as
select pri.product_name as pri_product_name, pro.product_name as pro_product_name
from price pri, product pro
where pri.product_name =* pro.product_name;
quit;


/* -------------------------------------------------------------------------------- */
Ksharp
Super User
Check function compare();


Ksharp

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 889 views
  • 0 likes
  • 3 in conversation