999 1

求高手解释下一段程序 [推广有奖]

  • 8关注
  • 2粉丝

讲师

33%

还不是VIP/贵宾

-

威望
0
论坛币
310 个
通用积分
0
学术水平
1 点
热心指数
1 点
信用等级
0 点
经验
15111 点
帖子
218
精华
0
在线时间
379 小时
注册时间
2012-10-31
最后登录
2020-8-31

楼主
慧(会)幸福 发表于 2013-5-17 08:58:09 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请教高手解释下下面第二个data步的意思,我对数组不明白,尤其是红色字体部分不明白:_s
  • 是什么意思啊,另外_s[5]不是被置为缺失了吗,怎么下面的 if 语句还有_s[k] <1?多谢各位了


    %let r =10;
    data a;
      call streaminit(1234);
      do sample =1 to &r;
        do i =1 to 6;
          x =rand('T',3) ;
          y =x/sqrt(3);
          output;
        end;
      end;
      keep sample i y;
    run;

    data shifts;
      set a;
      by sample;
      array _n[5] _temporary_(1:5);
      array _s[5] _temporary_;
    if first.sample then call missing(of _s
  • );
      do k =1 to dim(_n);
        if _s[k] <1 then if (sum ge (0.2+0.01*(_n[k]-1))) then do;
          _s[k] =1; n =_n[k]; cat ='shifts';
          output shifts;
    keep sample n i cat;
        end;
      end;
    run;

  • 二维码

    扫码加我 拉你入群

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

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

    关键词:求高手 data步 是什么意思 Data 请教高手 程序

    沙发
    yongyitian 发表于 2013-5-17 09:34:35
    /* there is no value for sum   */
    /*    sum = ?   */

    /* try this */
    %let sum=1;
    data shifts;
      set a;
      by sample;
      array _n[5] _temporary_(1:5);
      array _s[5] _temporary_(1:5);

    if first.sample then do;
                   do i = 1 to dim(_s);
                   call missing(_s(i)) ;
                   end; end;

      do k =1 to dim(_n);
              put '_C_   ' _all_;
              put '  ';
            if _s[k] <1 then if (&sum ge (0.2+0.01*(_n[k]-1))) then do;
              put '_D_   ' _all_;         
              put ' ';
          _s[k] =1; n =_n[k]; cat ='shifts';
          output shifts;
        end;
      end;
      keep sample n i cat;
    run;

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

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