首页 > 解决方案 > SAS: Apparent symbolic reference not resolved for Macro reference

问题描述

I have understood, and seen in other programs, that the following syntax is true.

%let variable = 'something';

statement name "&variable\othertext";        // something\othertext

However, in the code I have written I get this error message: Apparent symbolic reference not resolved. for the line LIBNAME REMOTE

%let month  =   'JUN';      
%let year   =   '18';       

%let    zos =   ***********
signon  zos     ********************;

libname name    "*********************************";

rsubmit;
libname remote  "AAAA.BBBB.&month&year.SASLIB"  access = readonly;

proc download inlib=remote outlib=name;
run;

libname remote clear;
endrsubmit;

signoff;

What am I missing?

标签: sas

解决方案


More context would help, but most likely you are not understanding the role that period plays in resolving macro variable (symbol) references. To allow you to place letters and digits next to macro variable references SAS needs a way to tell where the name of the macro ends and the plain text starts. Period is used for that.

So if you wanted to generate this string

"AAAA.BBBB.JAN18.SASLIB"

from month and year values. First make sure to set the macro variables to the text you actually want. Quotes are just text to the macro processor.

%let month=JAN ;
%let year= 18;

Then in when you replace the values with macro variable references you will need an extra period after &YEAR so that one actually is generated. You should probably just get in the habit of always adding the period when referencing a macro variable.

"AAAA.BBBB.&month.&year..SASLIB"

推荐阅读