【发布时间】:2016-10-26 11:22:21
【问题描述】:
我从其他地方窃取了一些代码来创建所有变量组合。我需要这个来创建多个回归,然后确定最好的。我喜欢输出,因为我可以使用一行并将所有变量的名称放在一个位置。
当我手动输入数据时,该数组有效,但这需要跨不同的数据工作并自行选择变量,因此我需要使用宏变量来输入数据。这应该不是问题,这适用于其他数据步骤。有人可以告诉我哪里出错了。
data test(keep=my_string);
length my_string $200.;
array a[4] $ ('new1' 'new2' 'new3' 'new4');
n = dim(a);
do k=1 to n;
do j=1 to comb(n,k);
call allcomb(j,k,of a[*]);
do i = 1 to k;
if i=1 then do; my_string="";counter=0;end;
counter=counter+1;
my_string=catx(" ",my_string, a[i]);
if counter=k then output;
end;
end;
end;
run;
下一个元素不起作用。只是给了我缺失的值 - 但它知道它需要 127 ...... subs 只是一个包含 new1-new7 的宏变量。
rsubmit;
data xx(keep=my_string);
length my_string $200.;
array a &subs;
n = dim(a);
do k=1 to n;
do j=1 to comb(n,k);
call allcomb(j,k,of a[*]);
do i = 1 to k;
if i=1 then do; my_string="";counter=0;end;
counter=counter+1;
my_string=catx(" ",my_string, a[i]);
if counter=k then output;
end;
end;
end;
run;
endrsubmit;
非常感谢您的帮助。
J
【问题讨论】: