以下是一段程序,请问各位SAS高手,以下这部分程序起到了什么作用?看不懂呢
if _n_=1 then count=0;count+y;
返回一个星期内的相对应的值的总和;数据如下:
20100101 34
20100102 37
20100103 67
20100104 67
20100105 67
20100106 67
20100107 67
20100108 67
20100109 67
20100110 67
20100111 67
20100112 67
20100113 67
20100114 67
20100115 67
20100116 67
20100117 67
20100118 67
代码:
data a;
input x y;
informat x yymmdd10.;
format x yymmdd10.;
xx=weekday(x);
cards;
20100101 34
20100102 37
20100103 67
20100104 67
20100105 67
20100106 67
20100107 67
20100108 67
20100109 67
20100110 67
20100111 67
20100112 37
20100113 67
20100114 67
20100115 67
20100116 67
20100117 67
20100118 67
;
data b;
set a end=last;
if _n_=1 then count=0;
count+y;
if xx=1 then do;
count=0;
count+y;
end;
if xx=7 or last then output;
run;
返回结果:
Obs x y xx count
1 2010-01-02 37 7 71
2 2010-01-09 67 7 469
3 2010-01-16 67 7 439
4 2010-01-18 67 2 134


雷达卡



京公网安备 11010802022788号







