Help using Base SAS procedures

Proc compare ignore case specificity

Reply
Contributor
Posts: 40

Proc compare ignore case specificity

[ Edited ]

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.

Trusted Advisor
Posts: 1,128

Re: Proc compare ignore case specificity

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
SAS Super FREQ
Posts: 3,476

Re: Proc compare ignore case specificity

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;

 

 

Contributor
Posts: 40

Re: Proc compare ignore case specificity

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.
SAS Super FREQ
Posts: 3,476

Re: Proc compare ignore case specificity

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.

Contributor
Posts: 40

Re: Proc compare ignore case specificity

Thanks for the explanation.
Ask a Question
Discussion stats
  • 5 replies
  • 420 views
  • 1 like
  • 3 in conversation