Chapter Contents

Previous

Next
%CMPRES and %QCMPRES

%CMPRES and %QCMPRES



Compress multiple blanks and remove leading and trailing blanks

Type: Autocall macros
Requires: MAUTOSOURCE system option


Syntax
Details
Examples
Example 1: Removing Unnecessary Blanks with %CMPRES
Example 2: Contrasting %QCMPRES and %CMPRES

Syntax

%CMPRES (text | text expression)
%QCMPRES (text | text expression)

Note:    Autocall macros are included in a library supplied by SAS Institute. This library may not be installed at your site or may be a site-specific version. If you cannot access this macro or if you want to find out if it is a site-specific version, see your SAS Software Consultant. For more information, see Chapter 9, "Storing and Reusing Macros," in SAS Macro Language: Reference.  [cautionend]


Details

The CMPRES and QCMPRES macros compress multiple blanks and remove leading and trailing blanks. If the argument might contain a special character or mnemonic operator, listed below, use %QCMPRES.

CMPRES returns an unquoted result, even if the argument is quoted. QCMPRES produces a result with the following special characters and mnemonic operators masked, so the macro processor interprets them as text instead of as elements of the macro language:

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


Examples

Example 1: Removing Unnecessary Blanks with %CMPRES

%macro createft;
   %let footnote="The result of &x &op &y is %eval(&x &op &y).";
   footnote1 &footnote;
   footnote2 %cmpres(&footnote);
%mend createft;

data _null_;
   x=5;
   y=10;
   call symput('x',x);    /* Uses BEST12. format */
   call symput('y',y);    /* Uses BEST12. format */
   call symput('op','+'); /* Uses $1. format     */
run;

%createft

The CREATEFT macro generates two footnote statements.

FOOTNOTE1 "The result of 5 + _________10 is _________15.";
FOOTNOTE2 "The result of 5 + 10 is 15.";

Example 2: Contrasting %QCMPRES and %CMPRES

%let x=5;
%let y=10;
%let a=%nrstr(%eval(&x   +   &y));
%put QCMPRES: %qcmpres(&a);
%put CMPRES: %cmpres(&a);

The %PUT statement writes the line

QCMPRES: %eval(&x + &y)
CMPRES: 15


Chapter Contents

Previous

Next

Top of Page

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