data dd;
set cds;
by id;
if last.id then id=.;
run;
[/code:1d7w60wl]作者: shiyiming 时间: 2012-8-17 07:35 标题: Re: 求助!数据集中插入空行并求和 data step can solve the problem.
[code:3jhjluok]data aggr;
set raw;
by id;
retain valeur1;
valeur1 + valeur;
output;
if last.id then
do;
valeur = valeur1;
valeur1=0;
id =.; output;
end;
drop valeur1;
run;[/code:3jhjluok]作者: shiyiming 时间: 2012-8-17 12:31 标题: Re: 求助!数据集中插入空行并求和 [code:fpfycogs]
data raw;
input val id;
datalines;
24 1
31 1
10 2
11 2
22 3
9 3
;
data ads;
set raw;
by id;
if first.id then subtot=0;
subtot+val;
output;
if last.id then do;
val=subtot;
id=.;
output;
end;
drop subtot;
run;
[/code:fpfycogs]作者: shiyiming 时间: 2012-8-17 23:17 标题: Re: 求助!数据集中插入空行并求和 在by后面加了notsorted
谢谢!