全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1127 7
2013-04-05
哪位高手能为我解释下下面的程序,尤其是从第四行往下的,尽量详细点,各个语句的意思及其作用,多谢了啊!我是菜鸟。
data shifts_drifts;
  set lstar;
  by sample;
  array _n[10] _temporary_ (1 2 3 4 5 6 7 8 9 10);
  array _s[10] _temporary_;  array _d[10] _temporary_;
  if first.sample then call missing(of _s[*] _d[*]);
  do k =1 to dim(_n);
    if _s[k] <1 then if (sum1 ge (2.01+0.01*(_n[k]-1))) then do;
      _s[k] =1; n =_n[k]; cat ='shifts';
      output shifts_drifts;
keep sample n i cat;
    end;
    if _d[k] <1 then if (sum2 ge (2.01+0.01*(_n[k]-1))) then do;
      _d[k] =1; n =_n[k]; cat ='drifts';
      output shifts_drifts;
keep sample n i cat;
    end;
  end;
run;



二维码

扫码加我 拉你入群

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

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

全部回复
2013-4-5 09:55:18
先看一看lstar 里面都有什么变量和数据
use
proc contents; =data=lstar; run;
proc print; data=lstar; run;

有没有 i, sample, 有几个 _n,_s, _d 。。。
二维码

扫码加我 拉你入群

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

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

2013-4-5 09:59:32
yongyitian 发表于 2013-4-5 09:55
先看一看lstar 里面都有什么变量和数据
use
proc contents; =data=lstar; run;
sample i  都有
二维码

扫码加我 拉你入群

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

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

2013-4-5 10:25:30
t seems that the if condition: _s[k]< 1 is failed.
It also seems the array variabes _k[10] and _d[10] are not initialized, which means that there is no value.

you need to check the initial value of the array variables _s[10] and _d[10]
To do this by issue a few put _all_ statement at different lines.

such as

data shifts_drifts;
  set lstar;
  by sample;
  array _n[10] _temporary_ (1 2 3 4 5 6 7 8 9 10);
  array _s[10] _temporary_;  array _d[10] _temporary_;
put ' _A_ ' put _all_;
  if first.sample then call missing(of _s[*] _d[*]);
put ' _B_ ' put _all_;
  do k =1 to dim(_n);
put ' _C_ ' put _all_;
    if _s[k] <1 then if (sum1 ge (2.01+0.01*(_n[k]-1))) then do;
put ' _D_ ' put _all_;
      _s[k] =1; n =_n[k]; cat ='shifts';
      output shifts_drifts;
keep sample n i cat;
    end;
    if _d[k] <1 then if (sum2 ge (2.01+0.01*(_n[k]-1))) then do;
      _d[k] =1; n =_n[k]; cat ='drifts';
      output shifts_drifts;
keep sample n i cat;
    end;
  end;
run;
二维码

扫码加我 拉你入群

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

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

2013-4-5 10:27:30
yongyitian 发表于 2013-4-5 10:25
t seems that the if condition: _s[k]< 1 is failed.
It also seems the array variabes _k[10] and _d[ ...
array _n[11] _temporary_ (1 2  3 4 5 6 7 8 9 10 11);
把括号里的数改成从1到1000,怎么改呢,请您继续执教
二维码

扫码加我 拉你入群

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

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

2013-4-5 10:32:26
not sure, try 1:1000 or 1-1000
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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