%let d=%nrstr( &sysday );
%put *&d* *%qleft(&d)* *%left(&d)*;
The %PUT statement writes the following line to the SAS log:
* &sysday * *&sysday * *Tuesday *
%LOWCASE and %QLOWCASE Autocall Macros
Change uppercase characters to lowercase.
Type: Autocall macros
Requirement: MAUTOSOURCE system option
Syntax
%LOWCASE text | text-expression()
%QLOWCASE (text | text-expression)
Without Arguments
See “KLOWCASE Function” in SAS National Language Support (NLS): Reference
Guide
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might 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 on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
The %LOWCASE and %QLOWCASE macros change uppercase alphabetic characters
to their lowercase equivalents. If the argument might contain a special character or
mnemonic operator, listed below, use %QLOWCASE.
%LOWCASE returns a result without quotation marks, even if the argument has
quotation marks. %QLOWCASE produces a result with the following special characters
and mnemonic operators masked so that 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 IN
Example: Creating a Title with Initial Letters Capitalized
%macro initcaps(title);
%global newtitle;
%let newtitle=;
%let lastchar=;
%do i=1 %to %length(&title);
%let char=%qsubstr(&title,&i,1);
%if (&lastchar=%str( ) or &i=1) %then %let char=%qupcase(&char);
%else %let char=%qlowcase(&char);
184 Chapter 13 AutoCall Macros
%let newtitle=&newtitle&char;
%let lastchar=&char;
%end;
TITLE "&newtitle";
%mend;
%initcaps(%str(sales: COMMAND REFERENCE, VERSION 2, SECOND EDITION))
Submitting this example generates the following statement:
TITLE "Sales: Command Reference, Version 2, Second Edition";
%QCMPRES Autocall Macro
Compresses multiple blanks, removes leading and trailing blanks, and returns a result that masks special
characters and mnemonic operators.
Type: Autocall macro
Requirement: MAUTOSOURCE system option
Syntax
%QCMPRES (text | text-expression)
Without Arguments
See “%CMPRES and %QCMPRES Autocall Macros” on page 179.
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might 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 on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
%QLEFT Autocall Macro
Left-aligns an argument by removing leading blanks and returns a result that masks special characters and
mnemonic operators.
Type: Autocall macro
Requirement: MAUTOSOURCE system option
Syntax
%QLEFT text | text-expression()
Without Arguments
See “%LEFT Autocall Macro” on page 183.
%QLEFT Autocall Macro 185
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might 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 on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
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 that 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 IN
Example: 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 that 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 *
%QLOWCASE Autocall Macro
Changes uppercase characters to lowercase and returns a result that masks special characters and
mnemonic operators.
Type: Autocall macro
Requirement: MAUTOSOURCE system option
Syntax
%QLOWCASE(text | text-expression)
Without Arguments
See “%LOWCASE and %QLOWCASE Autocall Macros” on page 184.
See “KLOWCASE Function” in SAS National Language Support (NLS): Reference
Guide
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might be a site-specific version. If you cannot access this
186 Chapter 13 AutoCall Macros
macro or if you want to find out if it is a site-specific version, see your on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
%QTRIM Autocall Macro
Trims trailing blanks and returns a result that masks special characters and mnemonic operators.
Type: Autocall macro
Requirement: MAUTOSOURCE system option
Syntax
%QTRIM (text | text-expression)
Without Arguments
See “%TRIM and %QTRIM Autocall Macro” on page 192.
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might 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 on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
%SYSRC Autocall Macro
Returns a value corresponding to an error condition.
Type: Autocall macro
Requirement: MAUTOSOURCE system option
Syntax
%SYSRC(character-string)
Required Argument
character-string
is one of the mnemonic values listed in Table 13.1 on page 188 or a text expression
that produces the mnemonic value.
Details
Note: Autocall macros are included in a library supplied by SAS. This library might not
be installed at your site or might 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 on-site SAS
support personnel. For more information, see “Storing and Reusing Macros” on page
115.
%SYSRC Autocall Macro 187
The SYSRC macro enables you to test for return codes produced by SCL functions, the
MODIFY statement, and the SET statement with the KEY= option. The SYSRC autocall
macro tests for the error conditions by using mnemonic strings rather than the numeric
values associated with the error conditions.
When you invoke the SYSRC macro with a mnemonic string, the macro generates a
SAS return code. The mnemonics are easier to read than the numeric values, which are
not intuitive and subject to change.
You can test for specific errors in SCL functions by comparing the value returned by the
function with the value returned by the SYSRC macro with the corresponding
mnemonic. To test for errors in the most recent MODIFY or SET statement with the
KEY= option, compare the value of the _IORC_ automatic variable with the value
returned by the SYSRC macro when you invoke it with the value of the appropriate
mnemonic.
The following table lists the mnemonic values to specify with the SYSRC function and a
description of the corresponding error.
Table 13.1 Mnemonics for Warning and Error Conditions
Mnemonic Description
Library Assign or Deassign Messages
_SEDUPLB The libref refers to the same physical library as another libref.
_SEIBASN The specified libref is not assigned.
_SEINUSE The library or member is not available for use.
_SEINVLB The library is not in a valid format for the access method.
_SEINVLN The libref is not valid.
_SELBACC The action requested cannot be performed because you do not
have the required access level on the library.
_SELBUSE The library is still in use.
_SELGASN The specified libref is not assigned.
_SENOASN The libref is not assigned.
_SENOLNM The libref is not available for use.
_SESEQLB The library is in sequential (tape) format.
_SWDUPLB The libref refers to the same physical file as another libref.
_SWNOLIB The library does not exist.
Fileref Messages
188 Chapter 13 AutoCall Macros
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset