Macro Variable Description
SQLXMSG Contains descriptive information and the DBMS-specific return
code for the error that is returned by the pass-through facility.
SQLXRC contains the DBMS-specific return code that is returned by the
pass-through facility.
Interfaces with the SAS Component Language
Using an SCL Program
You can use the SAS macro facility to define macros and macro variables for an SCL
program. Then, you can pass parameters between macros and the rest of the program.
Also, through the use of the autocall and compiled stored macro facilities, macros can be
used by more than one SCL program.
Note: Macro modules can be more complicated to maintain than a program segment
because of the symbols and macro quoting that might be required. Also,
implementing modules as macros does not reduce the size of the compiled SCL
code. Program statements generated by a macro are added to the compiled code as if
those lines existed at that location in the program.
The following table lists the SCL macro facility interfaces.
Table 8.3 SCL Interfaces to the Macro Facility
Category Tool Description
Read or Write SYMGET Returns the value of a global macro variable
during SCL execution.
SYMGETN Returns the value of a global macro variable
as a numeric value.
CALL SYMPUT Assigns a value produced in SCL to a global
macro variable.
CALL SYMPUTN Assigns a numeric value to a global macro
variable.
Note: It is inefficient to use SYMGETN to retrieve values that are not assigned with
SYMPUTN. It is also inefficient to use & to reference a macro variable that was
created with CALL SYMPUTN. Instead, use SYMGETN. In addition, it is
inefficient to use SYMGETN and CALL SYMPUTN with values that are not
numeric.
For more information about these elements, see “DATA Step Call Routines for Macros”
on page 237 and “DATA Step Functions for Macros” on page 249.
110 Chapter 8 Interfaces with the Macro Facility
How Macro References Are Resolved by SCL
An important point to remember when using the macro facility with SCL is that macros
and macro variable references in SCL programs are resolved when the SCL program
compiles, not when you execute the application. To further control the assignment and
resolution of macros and macro variables, use the following techniques:
If you want macro variables to be assigned and retrieved when the SCL program
executes, use CALL SYMPUT and CALL SYMPUTN in the SCL program.
If you want a macro call or macro variable reference to resolve when an SCL
program executes, use SYMGET and SYMGETN in the SCL program.
Referencing Macro Variables in Submit Blocks
In SCL, macro variable references are resolved at compile time unless they are in a
Submit block. When SCL encounters a name prefixed with an ampersand (&) in a
Submit block, it checks whether the name following the ampersand is the name of an
SCL variable. If so, SCL substitutes the value of the corresponding variable for the
variable reference in the submit block. If the name following the ampersand does not
match any SCL variable, the name passes intact (including the ampersand) with the
submitted statements. When SAS processes the statements, it attempts to resolve the
name as a macro variable reference
To guarantee that a name is passed as a macro variable reference in submitted
statements, precede the name with two ampersands (for example, &&DSNAME). If you
have both a macro variable and an SCL variable with the same name, a reference with a
single ampersand substitutes the SCL variable. To force the macro variable to be
substituted, reference it with two ampersands (&&).
Considerations for Sharing Macros between SCL Programs
Sharing macros between SCL programs can be useful, but it can also raise some
configuration management problems. If a macro is used by more than one program, you
must keep track of all the programs that use it so that you can recompile all of them each
time the macro is updated. Because SCL is compiled, each SCL program that calls a
macro must be recompiled whenever that macro is updated.
CAUTION:
Recompile the SCL program. If you fail to recompile the SCL program when you
update the macro, you run the risk of the compiled SCL being out of sync with the
source.
Example Using Macros in an SCL Program
This SCL program is for an example application with the fields BORROWED,
INTEREST, and PAYMENT. The program uses the macros CKAMOUNT and CKRATE
to validate values entered into fields by users. The program calculates the payment,
using values entered for the interest rate (INTEREST) and the sum of money
(BORROWED).
/* Display an error message if AMOUNT */
/* is less than zero or larger than 1000. */
%macro ckamount(amount);
Interfaces with the SAS Component Language 111
..................Content has been hidden....................

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