全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
957 1
2013-05-17
请教高手解释下下面第二个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;

  • 二维码

    扫码加我 拉你入群

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

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

    全部回复
    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;
    二维码

    扫码加我 拉你入群

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

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

    相关推荐
    栏目导航
    热门文章
    推荐文章

    说点什么

    分享

    扫码加好友,拉您进群
    各岗位、行业、专业交流群