Chapter Contents

Previous

Next
%LEFT and %QLEFT

%LEFT and %QLEFT



Left-align an argument by removing leading blanks

Type: Autocall macro
Requires: MAUTOSOURCE system option


Syntax
Details
Example
Contrasting %LEFT and %QLEFT

Syntax

%LEFT(text | text expression)
%QLEFT(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 LEFT macro and the QLEFT macro both left-align arguments by removing leading blanks. If the argument might contain a special character or mnemonic operator, listed below, use %QLEFT.

%LEFT returns an unquoted result, even if the argument is quoted. %QLEFT 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


Example

Example 1: Contrasting %LEFT and %QLEFT

In this example, both the LEFT and QLEFT macros remove leading blanks. However, the QLEFT macro protects the leading & in the macro variable SYSDAY so it does not resolve.

%let d=%nrstr(   &sysday   );
%put *&d* *%qleft(&d)* *%left(&d)*;

The %PUT statement writes the following line to the SAS log:

*   &sysday    * *&sysday   * *Tuesday   *


Chapter Contents

Previous

Next

Top of Page

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