Sas 将马尔克罗变量转换为宏

Sas 将马尔克罗变量转换为宏,sas,proc-sql,Sas,Proc Sql,下面我的代码1基于用户提示输入'Str'在Proc SQL中创建了一个where子句。我想使用一个宏(请参见下面的示例代码2)来替换宏变量。我怎样才能让它工作呢?谢谢 代码1: 代码2: 然后我可以像宏变量一样在SQL中使用宏 select xxx from t1, t2 where condition1 and condition2 %condition3(table=t6) 我不确定我是否完全理解你的问题。但是,如果您试图将代码1包装到宏中,并用宏函数替换datastep逻辑,则应该可以达

下面我的代码1基于用户提示输入'Str'在Proc SQL中创建了一个where子句。我想使用一个宏(请参见下面的示例代码2)来替换宏变量。我怎样才能让它工作呢?谢谢

代码1:

代码2:

然后我可以像宏变量一样在SQL中使用宏

select xxx from t1, t2 where condition1
and condition2
%condition3(table=t6)

我不确定我是否完全理解你的问题。但是,如果您试图将代码1包装到宏中,并用宏函数替换datastep逻辑,则应该可以达到以下目的:

%macro condition3(table, STR);
    %let STR_LIST = %sysfunc(putn(STR, z4.));
    and &table..store in ("&STR_LIST.")
%mend condition3;

proc sql;
    select xxx 
    from 
        t1, 
        t2 
    where 
        condition1 and
        condition2
        %condition3(t6, 34);
quit;   

如果您添加更多详细信息,并举例说明您正试图完成的工作,您将有更好的机会得到答案。@Curly_Jefferson从t1、t2中选择xxx,其中condition1和condition2%condition3此变量解析为“1234”中的t1.STR_SITE_NUM。1234是从用户输入的STR_列表,请参见代码1。现在我想使用宏而不是宏变量。所以,当我必须在SQL中从T1,T2更改为T6,T2时,它将类似于上面的代码2。或者这是不可能的?
select xxx from t1, t2 where condition1
and condition2
%condition3(table=t6)
%macro condition3(table, STR);
    %let STR_LIST = %sysfunc(putn(STR, z4.));
    and &table..store in ("&STR_LIST.")
%mend condition3;

proc sql;
    select xxx 
    from 
        t1, 
        t2 
    where 
        condition1 and
        condition2
        %condition3(t6, 34);
quit;