SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Improving Program Efficiency with Macro Variables
Creating Your Own Macro Variables


Unresolved Macro Variable References

What happens if a macro variable reference cannot be resolved? For example, suppose you revised your program to include a macro variable but misspelled the macro variable name when referencing it. What happens when you submit this program?

     %let year=1999;
     title "Temporary Employees for &year";
     data hrd.newtemp;
        set hrd.temp;
        if year(enddate)=&yera;
     run;
     proc print data=hrd.newtemp;
     run;

When SAS software encounters a macro variable reference but cannot locate a macro variable by that name, the reference is left unresolved and a warning message, such as the following, is written to the SAS log.


SAS Log
2  %let year=1999;
3  title "Temporary Employees for &year";
4  data hrd.newtemp;
5     set hrd.temp;
6     if year(enddate)=&yera;
                       -
                       390
WARNING: Apparent symbolic reference YERA not
         resolved.
NOTE: The SAS System stopped processing this step
      because of errors.
NOTE: The DATA statement used 0.78 seconds.

6  proc print data=hrd.newtemp;
7     title "Temporary Employees for &year";
8  run;

ERROR 390-185: Expecting a relational or an
      arithmetic operator.


SAS software continues scanning, but an unresolved macro variable reference often results in a syntax error. Syntax errors often occur because the ampersand that appears in an unresolved macro variable reference cannot be used in most SAS statements.


Troubleshooting

If you receive warning messages about unresolved macro variable references, check that

  • the macro variable references are spelled correctly
  • you do not reference a macro variable before defining it.


  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement