楼主: 小鳄鱼a
6060 12

取其中的变量循环 [推广有奖]

  • 6关注
  • 10粉丝

学科带头人

3%

还不是VIP/贵宾

-

威望
0
论坛币
125 个
通用积分
0.0040
学术水平
40 点
热心指数
45 点
信用等级
43 点
经验
32801 点
帖子
1185
精华
0
在线时间
1539 小时
注册时间
2009-7-16
最后登录
2018-10-5

40论坛币
macro a;
%let comind=

mend;

最佳答案

jl60156 查看完整内容

%macro test; %let x1=a; %let x2=b; %let x3=c; %let x4=d; %let x5=e; %let x6=f; %let x7=g; %let k=5; %let ncomb=%sysfunc(comb(7,&k)); %do j=1 %to &ncomb+1; %syscall allcomb(j, k, x1, x2, x3, x4, x5, x6, x7); %let ncomind&j=&x1, &x2, &x3, &x4, &x5; %put &&ncomind&j; data zonghe&j; set yourdata; commark=sum(&&ncomind&j); run; ...
关键词:Macro Mind acr CRO COM
沙发
jl60156 发表于 2014-11-29 09:48:48 |只看作者 |坛友微信交流群
%macro test;
   %let x1=a;
   %let x2=b;
   %let x3=c;
   %let x4=d;
   %let x5=e;
   %let x6=f;
   %let x7=g;
   %let k=5;
   %let ncomb=%sysfunc(comb(7,&k));
   %do j=1 %to &ncomb+1;
      %syscall allcomb(j, k, x1, x2, x3, x4, x5, x6, x7);
                  %let ncomind&j=&x1, &x2, &x3, &x4, &x5;
      %put  &&ncomind&j;
          data zonghe&j;
                  set yourdata;
                commark=sum(&&ncomind&j);
          run;
   %end;
%mend;
     
%test
已有 2 人评分论坛币 热心指数 收起 理由
admin_kefu + 30 根据规定进行奖励
小鳄鱼a + 5 + 3 精彩帖子

总评分: 论坛币 + 35  热心指数 + 3   查看全部评分

使用道具

藤椅
yongyitian 发表于 2014-11-29 11:12:13 |只看作者 |坛友微信交流群
  1. %let combind = a, b, c, d, e, f, g;
  2. data _null_;
  3.     combind = compress("&combind", ",");
  4.       n = 7;
  5.       length combind5 $20;
  6.       do i = 1 to 5;
  7.       nth = ceil(ranuni(123)*n);
  8.       combind5 = catx(', ', combind5, scan(combind, nth));
  9.       combind = compress(combind, scan(combind, nth));
  10.       n = n - 1;
  11.     end;
  12.   call symput('ncombind', combind5);
  13. run;
  14. %put &ncombind;
复制代码
已有 1 人评分论坛币 热心指数 收起 理由
小鳄鱼a + 5 + 2 精彩帖子

总评分: 论坛币 + 5  热心指数 + 2   查看全部评分

使用道具

板凳
bobguy 发表于 2014-11-29 13:01:55 |只看作者 |坛友微信交流群
Take a look ,

1) CALL RANPERK(seed, k, variable-1 <, variable–2, ...>);
2) CALL RANPERM(seed, variable-1 <, variable–2, ...>);

使用道具

报纸
小鳄鱼a 发表于 2014-11-29 19:25:32 |只看作者 |坛友微信交流群
yongyitian 发表于 2014-11-29 11:12
结果   
5719   %put &ncombind;
f, b, a, g, d



我是想把7中抽取5个全部的结果都输出来

使用道具

地板
小鳄鱼a 发表于 2014-11-29 19:26:16 |只看作者 |坛友微信交流群
bobguy 发表于 2014-11-29 13:01
Take a look ,

1) CALL RANPERK(seed, k, variable-1 );
高手   能否具体一下   

使用道具

7
yongyitian 发表于 2014-11-29 23:35:45 |只看作者 |坛友微信交流群
小鳄鱼a 发表于 2014-11-29 19:25
结果   
5719   %put &ncombind;
f, b, a, g, d
7中抽取5的全部结果与任取5个完全不同, 但可能简单一点.

you may use allcomb() function;
http://support.sas.com/documenta ... .htm#a003112305.htm

使用道具

8
名叫旺达的鱼 发表于 2014-11-30 00:38:16 |只看作者 |坛友微信交流群
支持支持,加油加油加油

使用道具

9
wzw03 发表于 2014-11-30 09:27:14 |只看作者 |坛友微信交流群
牛人啊!

使用道具

10
feiying1023 发表于 2014-11-30 09:35:14 |只看作者 |坛友微信交流群
好厉害啊,都看不懂啊?

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-20 01:59