BookmarkSubscribeRSS Feed
nbonda
Obsidian | Level 7

Is there any method,option or statement to ignore case sensitivity for variables.

example:

datasetA:

 

name

daniel

 

datasetB:

 

name

Daniel

 

if I compare using Proc Compare ,datasetA and datasetB, results showing as diferences in two datasets.

How to make proc compare case insensitive?

 

thanks in advance.

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16
I do not think we have any such option in proc compare which ignores the case. We have to update the data in the dataset and perform the proc compare.
Thanks,
Jag
Rick_SAS
SAS Super FREQ

PROC COMPARE compares raw values. If you want a case-insensitive comparison, you can use the UPCASE function or the $UPCASE format to transform character data. You can either do this directly in the DATA step, or you can create data VIEWS that contain the upcase version of character data. For example:

 

/* create second data set with lowercase names */
data class2;
set sashelp.class;
Name = lowcase(Name);
run;

/* create data views with upcase names */
data BaseData / view=BaseData;
set sashelp.class;
NewName = upcase(Name);
run;
data CompareData / view=CompareData;
set class2;
NewName = upcase(Name);
run;

/* compare the upcase values */
proc compare base=BaseData compare=CompareData;
var NewName;
run;

 

 

nbonda
Obsidian | Level 7
Thank you for your reply..I did same thing as I have issue with only two variable. there are 100 character variable in these datasets. it will be lot of code to change to upper case for all of them. It would have been easy if SAS has some kind of options to ignore case in Proc Compare.
Rick_SAS
SAS Super FREQ

I agree that this could be useful for analysts who processes English strings (in general, use the Roman alphabet). I seem to recall this request on the SAS Software ballot in the early 2000s. However, that was about the same time that SAS was going global. Many SAS customers process  text in Japanese, Chinese, Korean, and other languages for which "uppercase" does not make sense.  I'm not making excuses, and I don't have any knowldege about why there isn't a case-insensitive option, but I mention non-Latin languages as a possible reason why this feature was never added.

nbonda
Obsidian | Level 7
Thanks for the explanation.

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
  • 5 replies
  • 5703 views
  • 1 like
  • 3 in conversation