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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 983 views
  • 0 likes
  • 3 in conversation