【发布时间】:2014-09-12 15:36:55
【问题描述】:
在 Proc SQL 中,我想使用宏变量&condition3,但我想将宏变量中的字符串“t1”替换为“t6”。如何使以下公式起作用:translate(&condition3,'T6','T1')?
顺便说一句,&condition3 解析为:and t1.store in ('1234')
完整的查询:
Proc sql;
Create table xxx as
Select....
From ...
Where condition1
And condition 2
&condition3
【问题讨论】:
-
乔,非常感谢您的及时回复!在日志中:&condition3 解析为:和 T1.STR_SITE_NUM in ("1542") 但在 %sysfunc 中它解析为:和 T6.STR_SITE_NUM in ("6542") 你知道为什么 1542 解析为 6542 吗?它不会像那样直接工作,我必须将 %sysfunc(translate(&condition3,t6,t1)) 放在 condition2 之后的宏中。再次感谢!稍后我会尝试你的宏示例。
-
因为“翻译”不正确...将更新答案。将来,如果您的评论是针对答案的,请对答案发表评论。
-
@Joe 我想在那里尝试您的宏示例,但是如何转换我的宏变量?我最初从互联网上获得了以下代码。 'Str' 是用户提示输入。
%global STR_COUNT STR; %让 STR_WHERE_CLAUSE=;数据 <i>null</i>; /*Data whereclause;*/ if missing(symget('str'))=0 then do;长度STR_LIST $1000; STR1=symget('STR'); STR2=put(输入(STR1,best4.),z4.); STR_LIST=报价(STR2);把STR_LIST;结尾;如果缺少(STR_LIST)=0,则调用 symputx('STR_WHERE_CLAUSE',cats(' and T1.STR_SITE_NUM in (',STR_LIST,')'));跑; %PUT &STR_Where_Clause; -
@Joe 我在下面的链接中打开了另一个问题线程。谢谢! stackoverflow.com/questions/25852859/…