Chapter Contents

Previous

Next
%UPCASE and %QUPCASE

%UPCASE and %QUPCASE



Convert values to uppercase

Type: Macro functions
See also:
%LOWCASE and %QLOWCASE
%NRBQUOTE
%QLOWCASE


Syntax
Details
Comparison
Examples
Example 1: Capitalizing a Value to be Compared
Example 2: Comparing %UPCASE and %QUPCASE

Syntax

%UPCASE (character string | text expression)
%QUPCASE(character string | text expression)


Details

The %UPCASE and %QUPCASE functions convert lowercase characters in the argument to uppercase. %UPCASE does not mask special characters or mnemonic operators in its result, even when the argument was previously masked by a macro quoting function. If a value might contain a special character or mnemonic operator, use %QUPCASE.

If the argument might contain a special character or mnemonic operator, listed below, use %QUPCASE. %QUPCASE masks the following special characters and mnemonic operators in its result:

& % ' " ( ) + - * / < > = ¬ ^ ~ ; , blank
AND OR NOT EQ NE LE LT GE GT

%UPCASE and %QUPCASE are useful in the comparison of values because the macro facility does not automatically convert lowercase characters to uppercase before comparing values.


Comparison


Examples

Example 1: Capitalizing a Value to be Compared

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 %upcase(&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:

%runreport(DEC)
%runreport(Dec)
%runreport(dec)

Example 2: Comparing %UPCASE and %QUPCASE

These statements show the results produced by %UPCASE and %QUPCASE:

%let a=begin;
%let b=%nrstr(&a);

%put UPCASE produces: %upcase(&b);
%put QUPCASE produces: %qupcase(&b);

Executing these statements writes this to the SAS log:

UPCASE produces: begin
QUPCASE produces: &A


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.