Macro Functions for NLS |
Category: | DBCS |
Type: | NLS macro function |
Syntax | |
Details | |
Examples | |
Example 1: Capitalizing a Value to be Compared | |
Example 2: Comparing %KUPCASE and %QKUPCASE |
Syntax |
%KUPCASE (character string | text expression) |
%QKUPCASE (character string | text expression) |
Details |
The %KUPCASE and %QKUPCASE functions convert lowercase characters in the argument to uppercase. %KUPCASE does not mask special characters or mnemonic operators in its results.
If the argument contains a special character or mnemonic operator, listed here, use %QKUPCASE. %QKUPCASE masks the following special characters and mnemonic operators in its results:
& % ' " ( ) + - * / < > = ¬ ^ ~ ; , # blank AND OR NOT EQ NE LE LT GE GT IN
%KUPCASE and %QKUPCASE are useful in comparing values because the macro facility does not automatically convert lowercase characters to uppercase before comparing them.
Examples |
In this example, the macro RUNREPT compares a value input for the macro variable MONTH to the string DEC. If the uppercase value of the response is DEC, then PROC FSVIEW runs on the data set REPORTS.ENDYEAR. Otherwise, PROC FSVIEW runs on the data set with the name of the month in the REPORTS data library.
%macro runrept(month); %if %kupcase(&month)=DEC %then %str(proc fsview data=reports.endyear; run;); %else %str(proc fsview data=reports.&month; run;); %mend runrept;
You can invoke the macro in any of these ways to satisfy the %IF condition:
%runrept(DEC) %runrept(Dec) %runrept(dec)
These statements show the results produced by %KUPCASE and %QKUPCASE:
%let a=begin; %let b=%nrstr(&a); %put KUPCASE produces: %kupcase(&b); %put QKUPCASE produces: %qkupcase(&b);
When these statements execute, the following is written to the SAS log:
KUPCASE produces: begin QKUPCASE produces: &A
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.