| 
 | 
地板
 
 
 楼主 |
发表于 2012-7-10 03:34:21
|
只看该作者
 
 
 
Re: 如何求n个观测的组合?
C(100, 80)==5.3598337E20 
Are you sure you want all of them 
 
nevertheless, you can use ALLCOMB() function in SAS to enumerate all combinations, up to COMB(100, 80); 
here is a sample code from SAS Doc 
[code:2z8wl18r] 
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; 
      rc=allcomb(j, k, of x[*]); 
      put j 5. +3 x1-x3 +3 rc=; 
   end; 
run; 
[/code:2z8wl18r] 
 
you simply change x[5] to x[100] ; 
 
[quote="MerlinZHOU":2z8wl18r]数据集ads中有一个变量x,有n个观测。 
如果要求出其中的两两组合,且考虑顺序, 
可用如下程序,或用iml做两个循环, 
[code:2z8wl18r] 
 
%let n=5; 
 
data ads; 
do x=1 to &n; 
   output; 
end; 
run; 
 
proc sql noprint; 
  create table bds as  
  select ads.x, ads_copy.x as y 
  from ads, ads ads_copy 
  where ads.x<ads_copy.x; 
quit; 
 
[/code:2z8wl18r] 
 
问题是如果n很大,例如n=100,我们要求出其中80个的组合 
且考虑顺序,该如何求(sql最大能连接32张表,矩阵循环要做80次?)? 
恳请各位sasor,指点一下。[/quote:2z8wl18r] |   
 
 
 
 |