楼主: nuomaniya
1422 9

如何快速生成组合 [推广有奖]

  • 1关注
  • 0粉丝

大专生

33%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
218 点
帖子
22
精华
0
在线时间
65 小时
注册时间
2013-1-16
最后登录
2015-11-2

楼主
nuomaniya 发表于 2013-10-26 17:23:36 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
有变量VAR1-VAR5,每个变量可取值是0、1、3、7 现在希望生成所有可能的组合,求一个比较快速方法,谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:如何快速 VaR 如何

沙发
bobguy 发表于 2013-10-26 22:59:32
That will be a very big data.
if a variable has length 3=3*8 bytes=24 bytes which I think is the minimum length on PC or unix.
4**20*(4*24)=105,553,116,266,496 bytes

藤椅
nuomaniya 发表于 2013-10-26 23:27:08
bobguy 发表于 2013-10-26 22:59
That will be a very big data.
if a variable has length 3=3*8 bytes=24 bytes which I think is the mi ...
没考虑周到,修改过了,顺便问一句,为啥是(4*24)?

板凳
bobguy 发表于 2013-10-27 00:11:27
nuomaniya 发表于 2013-10-26 23:27
没考虑周到,修改过了,顺便问一句,为啥是(4*24)?
one variable needs 3*8=24 bytes. four variables need 4*24

报纸
nuomaniya 发表于 2013-10-27 00:46:25
bobguy 发表于 2013-10-27 00:11
one variable needs 3*8=24 bytes. four variables need 4*24
怎么写程序,能否指导下,谢谢?

地板
bobguy 发表于 2013-10-27 03:46:01
nuomaniya 发表于 2013-10-27 00:46
怎么写程序,能否指导下,谢谢?
The question is too general and too big.

For your particular question, I think the fastest way is,


data need;
  do var1=0,1,3,7;
     do var2=0,1,3,7;
            do var3=0,1,3,7;
                  do var4=0,1,3,7;
                     do var5=0,1,3,7;
                            output;
                         end;
                  end;
                end;
         end;
        end;
run;

I only do five variables, same logic will do more variables. Since it is a Cartesian product, the needed space grows up quickly.

7
nuomaniya 发表于 2013-10-27 09:30:36
bobguy 发表于 2013-10-27 03:46
The question is too general and too big.

For your particular question, I think the fastest way ...
谢谢您了,请问如果有更多变量有没有快捷的办法,不想一个一个DO下来。

8
wwang111 发表于 2013-10-28 11:33:14
试试这个:

data test;
length var1 var2 var3 var4 var5 8;
run;
proc transpose data=test out=test_(keep=_name_);
var var1-var5;
run;

data _null_;
set test_ end=last nobs=nobs;
length code $1000. ;
retain code;
if _n_=1 then code="data wanted; do "||strip(_name_)||"=0,1,3,7;";
else code=trim(code)||"do "||strip(_name_)||"=0,1,3,7;";
if last then do;
  code=trim(code)||'output;';
  do i=1 to nobs;
  code=trim(code)||'end;';
  end;
  code=trim(code)||'run;';
  call execute(code);
end;
run;
只有一个罗纳尔多

9
nuomaniya 发表于 2013-10-28 16:36:55
谢谢,没想到还可以这样循环。

10
rdwalk 发表于 2013-10-29 07:07:53
python里面有排列组合的函数,也可试一下

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-4 11:35