【问题标题】:Is there a function to check if an element exist in a macro variable?是否有检查宏变量中是否存在元素的功能?
【发布时间】:2020-01-21 13:29:58
【问题描述】:

我有一个表 Z 有两列 a(string) 和 b(integer) 每个会话的变化中的元素,所以我为每个会话创建一个宏变量!

%Let Fe='abc','def','mno';
%let mylist = &session_1. &session_2. &session_3.;

%macro print_session_3(mylist) / minoperator ; 
%let session_3=session_3;
    %IF  &session_3. in &mylist. %THEN %DO;
        proc sql;
            create table DATA.session_3 as
        select  a , b
        from source.Z
            where a in &Fe.
        and b>4
    ;quit;
    %end; 
%mend;
%print_session_3(&mylist);

我希望这对你来说已经足够清楚了,错误是:"Expecting a )"

【问题讨论】:

    标签: sql sas sas-macro


    【解决方案1】:

    这意味着你错过了)

    您应该在where 语句中使用in 运算符和() 中的值列表。

    它看起来像:

    where a in (&Fe.)
    

    【讨论】:

    • 非常感谢,我在 () 中添加了一个,但我没有尝试添加 &Fe。
    猜你喜欢
    • 2011-03-12
    • 2011-04-16
    • 2016-10-10
    • 1970-01-01
    • 2012-11-20
    相关资源
    最近更新 更多