data test;
input serial var $;
datalines;
1 v1
2 v2
3 v3
;
run;
proc sql;
create table tmp as(
select var as newvar from test union all
select cat(a.var,b.var) as newvar from test a,test b where a.serial<b.serial union all
select cat(a.var,b.var,c.var) as newvar from test a,test b,test c where a.serial<b.serial and b.serial<c.serial);
quit;
data fstr;
set tmp;
serial +1;
run;
proc sql;
select newvar into :str1 from fstr where serial=1;
select newvar into :str2 from fstr where serial=2;
select newvar into :str3 from fstr where serial=3;
select newvar into :str4 from fstr where serial=4;
select newvar into :str5 from fstr where serial=5;
select newvar into :str6 from fstr where serial=6;
quit;
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.
data _null_;
array x[5] $3 ('ant' 'bee' 'cat' 'dog' 'ewe');
n=dim(x);
k=3;
ncomb=comb(n,k);
do j=1 to ncomb+1;
call allcomb(j, k, of x
);
put j 5. +3 x1-x3;
end;
run;
SAS writes the following output to the log:
1 ant bee cat
2 ant bee ewe
3 ant bee dog
4 ant cat dog
5 ant cat ewe
6 ant dog ewe
7 bee dog ewe
8 bee dog cat
9 bee ewe cat
10 dog ewe cat
11 dog ewe cat
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.
%comb(0,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(1,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(2,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(3,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(4,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(5,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(6,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(7,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(8,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(9,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(10,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(11,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(12,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
%comb(13,one two three four five six seven eight nine ten 11 12 13,out=hell)
proc append base=hell1 data=hell;
proc print data=hell1;
options notes;
复制代码
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.