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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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