
data temp;
input name $ withdraw save ;
cards;
Xiaowang 300 500
XiaoLi 100 200
XiaoZhang 400 500
XiaoLi 400 30
XiaoZhang 380 230
XiaoLi 440 30
;
run;
/*agrregate the dataset based on name*/
proc univariate data = temp noprint;
class name;
var withdraw;
output out = name;
run;
/*save each customer name into marcro*/
data _null_;
set name;
suffix=put(_n_,5.);
call symput (cats("name",suffix), trim(name));
call symput ("total", _n_);
run;
/*create dataset for each customer*/
%macro createdata();
%do i = 1 %to &total;
data &&name&i;
set temp;
if name ne "&&name&i" then delete;
run;
%end;
%mend;
%createdata();
[此贴子已经被作者于2007-11-20 6:59:39编辑过]