函数symexist如何工作?

时间:2017-05-15 00:58:45

标签: sas

我认为symexist用于检查宏变量(本地变量)。我做了一个测试,但输出超出了我的预期。代码是:

DevTools failed to parse SourceMap: http://MYSERVER.com/upct/src/css/bootstrap.css.map

输出结果为:

%macro test(t1,t2);
%if %symexist(t1) %then %put &t1. is exist;
%if %symexist(t2) %then %put &t2. is exist;
%mend;
%test(test1,);

查看mlogic:%IF条件%symexist(t2)为TRUE。 t2没有宏变量。怎么来真的?任何人来解释symexist如何工作?我有一个搜索但没有找到。

谢谢, 安德烈

2 个答案:

答案 0 :(得分:3)

有一些名为T1和T2的宏变量,因为您通过将它们设置为宏来定义它们。所有宏参数都是宏的局部宏变量。

答案 1 :(得分:2)

你需要使用& t1而不是t1因为你想测试test1的存在而不是t1的存在。

但它仍会出错,因为宏变量t2不存在。

%let test1 = Yes;

%macro test(t1, t2);
    %if %symexist(&t1) %then
        %put &t1. is exist;

    %if %symexist(&t2) %then
        %put &t2. is exist;
    %else
        %put &t2. does not exist;
%mend;

%test(test1, test2);

输出将是:

  

test1存在

     

test2不存在