Fixing Autocall Library Specifications
When an autocall library specification causes an error, it is because the macro processor
cannot find the member containing the autocall macro definition in the library or
libraries specified in the SASAUTOS system option.
To correct this error, follow these steps.
1. If the unresolved macro call created an invalid SAS statement, submit a single
semicolon to terminate the invalid statement. SAS is then able to correctly recognize
subsequent statements.
2. Look at the value of the SASAUTOS system option by printing the output of the
OPTIONS procedure or by viewing the OPTIONS window in the SAS windowing
environment. (Or, edit your SAS configuration file or SAS autoexec file.) Verify
each fileref or directory name. If you find an error, submit a new OPTIONS
statement or change the SASAUTOS setting in the OPTIONS window.
3. Check the MAUTOSOURCE system option. If SAS could not open at least one
library, it sets the NOMAUTOSOURCE option. If NOMAUTOSOURCE is present,
reset MAUTOSOURCE with a new OPTIONS statement or the OPTIONS window.
4. If the library specifications are correct, check the contents of each directory to verify
that the autocall library member exists and that it contains a macro definition of the
same name. If the member is missing, add it.
5. Set the MRECALL option with a new OPTIONS statement or the OPTIONS
window. By default, the macro processor searches only once for an undefined macro.
Setting this option causes the macro processor to search the autocall libraries for the
specification again.
6. Call the autocall macro, which includes and submits the autocall macro source.
7. Reset the NOMRECALL option.
Note: Some host environments have environment variables or system-level logical
names assigned to the SASAUTOS library. Check your SAS companion
documentation for more information about how the SASAUTOS library
specification is handled in your host environment.
Fixing Autocall Macro Definition Errors
When the autocall facility locates an autocall library member, the macro processor
compiles any macros in that library member. It stores the compiled macros in the catalog
containing stored compiled macros. For the rest of your SAS session, invoking one of
those macros retrieves the compiled macro from the Work library. Under no
circumstances does the autocall facility use an autocall library member when a compiled
macro with the same name already exists. Thus, if you invoke an autocall macro and
discover you made an error when you defined it, you must correct the autocall library
member for future use. Compile the corrected version directly in your program or
session.
To correct an autocall macro definition in a windowing environment, do the following:
1. Use the INCLUDE command to bring the autocall library member into the SAS
Code Editor window. If the macro is stored in a catalog SOURCE entry, use the
COPY command to bring the program into the Code Editor window.
Troubleshooting Your Macros 133
2. Correct the error.
3. Store a copy of the corrected macro in the autocall library with the FILE command
for a macro in an external file or with a SAVE command for a macro in a catalog
entry.
4. Submit the macro definition from the Code Editor window.
The macro processor then compiles the corrected version, replacing the incorrect
compiled macro. The corrected, compiled macro is now ready to execute at the next
invocation.
To correct an autocall macro definition in an interactive line mode session, do the
following:
1. Edit the autocall macro source with a text editor.
2. Correct the error.
3. Use a %INCLUDE statement to bring the corrected library member into your SAS
session.
The macro processor then compiles the corrected version, replacing the incorrect
compiled macro. The corrected, compiled macro is now ready to execute at the next
invocation.
File and Macro Names for Autocall
When you want to use a macro as an autocall macro, you must store the macro in a file
with the same name as the macro. Also, the file extension must be .sas (if your
operating system uses file extensions). If you experience problems with the autocall
facility, be sure the macro and filenames match and the file has the right extension when
necessary.
Displaying Information about Stored Compiled Macros
To display the list of entries in a catalog containing compiled macros, you can use the
Catalog window or the CATALOG procedure. The following PROC step displays the
contents of a macro catalog in a SAS library identified with the libref MYSASLIB:
libname mysaslib
'SAS-library';
proc catalog catalog=mysaslib.sasmacr;
contents;
run;
quit;
You can also use PROC CATALOG to display information about autocall library macros
stored in SOURCE entries in a catalog. You cannot use PROC CATALOG or the
Explorer window to copy, delete, or rename stored compiled macros.
You can use the MCOMPILENOTE system option to issue a note to the log upon the
completion of the compilation of any macro. For more information, see
“MCOMPILENOTE System Option” on page 360.
In SAS 6.11 and later, you can use PROC SQL to retrieve information about all
compiled macros. For example, submitting these statements produces output similar to
the following output:
134 Chapter 10 Macro Facility Error Messages and Debugging
proc sql;
select * from dictionary.catalogs
where memname in ('SASMACR');
Output 10.1 Output from PROC SQL Program for Viewing Compiled Macros
Library Member Member Object Object Date Object
Name Name Type Name Type Object Description Modified Alias
-------------------------------------------------------------------------------------------
WORK SASMACR CATALOG FINDAUTO MACRO 05/28/96
SASDATA SASMACR CATALOG CLAUSE MACRO Count words in clause 05/24/96
SASDATA SASMACR CATALOG CMPRES MACRO CMPRES autocall macro 05/24/96
SASDATA SASMACR CATALOG DATATYP MACRO DATATYP autocall macro 05/24/96
SASDATA SASMACR CATALOG LEFT MACRO LEFT autocall macro 05/24/96
To display information about compiled macros when you invoke them, use the SAS
system options MLOGIC, MPRINT, and SYMBOLGEN. When you specify the SAS
system option MLOGIC, the libref and date of compilation of a stored compiled macro
are written to the log along with the usual information displayed during macro
execution.
Solving Problems with Expression Evaluation
The following macro statements use the %EVAL function:
Table 10.3 Macro Statements That Use the %EVAL Function
%DO %IF-%THEN %SCAN
%DO %UNTIL %QSCAN %SYSEVALF
%DO %WHILE %QSUBSTR %SUBSTR
In addition, you can use the %EVAL function to specify an expression evaluation.
The most common errors that occur while evaluating expressions are the presence of
character operands where numeric operands are required or ambiguity about whether a
token is a numeric operator or a character value. Chapter 6, “Macro Expressions,” on
page 73 discusses these and other macro expression errors.
Quite often, an error occurs when a special character or a keyword appears in a character
string. Consider the following program:
%macro conjunct(word= );
%if &word = and or &word = but or &word = or %then /* ERROR */
%do %put *** &word is a conjunction. ***;
%else
%do %put *** &word is not a conjunction. ***;
%mend conjunct;
Troubleshooting Your Macros 135
..................Content has been hidden....................

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