![]() | ![]() | ![]() |
This program creates several macro variables. It constructs a data set name and stores it in the macro variable DSNAME by concatenating the values of the two macro variables, MYLIB and MEMBERNAME. The %SYSFUNC macro function opens the data set, retrieves the time of the last update of the data set, and then formats that information for inclusion in a TITLE statement.
This code does not execute correctly. A second period is needed between &MYLIB and &MEMBERNAME in the %LET statement for DSNAME. The first period terminates the macro variable reference. A second period would be included as text in the macro variable value. With that second period missing, DSNAME does not resolve to the name of an existing data set. Therefore, none of the statements containing the %SYSFUNC macro function execute as expected.
Original Program
|
The following SAS log shows errors, but without knowing the exact value of the macro variables, it is difficult to determine the source of the problem.
SAS Log
|
The title resolves as follows:
Submitting the following %PUT statements displays the values assigned to the macro variables.
The following SAS log shows that the value of DSNAME is not the name of the data set that was supposed to be examined. The data set CORPLIBITEMS was not successfully opened either, since the value of DSID, the data set ID, is zero.
SAS Log
|
The revised %LET statement for DSNAME is
The TITLE statement now resolves to the following:
SAS Log
|
About the Author
The author of Debugging SAS Programs: A Handbook of Tools and Techniques as well as SAS Macro Programming Made Easy, Michele Burlew is a self-employed SAS programmer with more than 20 years of experience. She specializes in designing and programming a variety of SAS applications, and she has expertise in using many SAS products. Michele's extensive experience in developing programs and working with end users gives her keen insight into the needs of SAS software users.
Her books are available from the online bookstore.
| Type: | Sample |
| Topic: | Internal Administration ==> BBU Non SAS Authors ==> Michele Burlew SAS Reference ==> Macro |
| Date Modified: | 2005-10-08 03:03:26 |
| Date Created: | 2005-02-21 14:46:04 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | All | 6.12 | n/a |



