1183 7

求教 解释一段程序 [推广有奖]

  • 8关注
  • 2粉丝

讲师

33%

还不是VIP/贵宾

-

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

楼主
慧(会)幸福 发表于 2013-4-5 09:25:23 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
哪位高手能为我解释下下面的程序,尤其是从第四行往下的,尽量详细点,各个语句的意思及其作用,多谢了啊!我是菜鸟。
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;



二维码

扫码加我 拉你入群

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

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

关键词:TEMPORARY missing Sample Shifts array 程序

沙发
yongyitian 发表于 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  都有

板凳
yongyitian 发表于 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,怎么改呢,请您继续执教

地板
yongyitian 发表于 2013-4-5 10:32:26
not sure, try 1:1000 or 1-1000

7
yongyitian 发表于 2013-4-5 10:53:52
慧(会)幸福 发表于 2013-4-5 10:27
array _n[11] _temporary_ (1 2  3 4 5 6 7 8 9 10 11);
把括号里的数改成从1到1000,怎么改呢,请您继续 ...
data test;
  array _k[100] _temporary_ (1:100);
  array _d[100] _temporary_ (1:100);
  array _p[100] _temporary_ ;
put 'A ' _all_;
    do i=1 to 100;
          _p(i) = 100;
          put _k(i)=;
          put _d(i)=;
          put _p(i)=;
   end;
run;

8
慧(会)幸福 发表于 2013-4-5 11:08:48
yongyitian 发表于 2013-4-5 10:53
data test;
  array _k[100] _temporary_ (1:100);
  array _d[100] _temporary_ (1:100);
非常感谢,搞定了

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

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