【发布时间】:2021-03-21 07:10:43
【问题描述】:
我偶然发现了以下代码 sn-p,其中变量 top3 必须从表 have 中填充,而不是从数字数组中填充。
%let top3 = 14 15 42; /* This should be made obsolete.. */
%let no = 3;
proc sql;
create table want as
select *
from (select x, y from foo) a
%do i = 1 %to &no.;
%let current = %scan(&top3.,&i.); /* What do I need to put here? */
left join (select x, y from bar where z=¤t.) row_¤t.
on a.x = row_¤t..x
%end;
;
quit;
表have 包含字符串中的xs,如下所示:
i x
1 14
2 15
3 42
我现在想知道如何修改%let current = ... 行,以便从表have 填充current。我知道如何使用proc sql 和select .. into 填充宏变量,但恐怕我现在的做法完全违背了SAS 哲学。
【问题讨论】:
-
为什么原始查询使用 %DO 循环而不是仅仅执行
select x, y from bar where z in (&top3)?您不能有多个名为 Y 的变量,您是否过度简化了示例?
标签: sas