I have stolen a bit of code from elsewhere to create all combinations of variables. I need this to create multiple regressions and then determine the best. I like the output as I can then use a line and have all the names of the variables in 1 place.
The array works when I enter the data manually, but this needs to work across different data and self select the variables so I need to use a macro variable to input the data. This shouldn't be a problem, this works with other datasteps. Can someone tell me where I'm going wrong.
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;
This next element doesn't work. Just gives me missing values - but it knows it needs 127... subs is just a macro variable with new1-new7 in it.
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;
Your help is very much appreciated.
J