|
|
Re: sas一个取最大值的问题[求助,急!!!]
真的太感谢你了:)
你的这个方法比我那个明显好。。。
基本问题都解决,受教了受教了!!!
[quote="死猪头":3uagxwrw]猪头又上当了!
mz同学你说得不错,可以施采补之术,在第一个proc sort后加
[code:3uagxwrw]
data zhutou(drop=last_year);
do until (last.company);
do until(last.industry);
set zhutou;
by company industry;
end;
last_year = max(year, last_year);
end;
do until (last.company);
do until(last.industry);
set zhutou;
by company industry;
output;
end;
if year<last_year then do;
year = last_year;
count=.;
output;
end;
end;
run;
proc expand data=zhutou out=zhutou from=day;
id year;
by company industry;
convert count/method=none;
run;
[/code:3uagxwrw]
也可以自行采补,将data sizhutou步换成
[code:3uagxwrw]
data sizhutou(drop=count year prev_year last_year rename=(year1=year));
do until (last.company);
do until(last.industry);
set zhutou;
by company industry;
end;
last_year = max(year, last_year);
end;
do until (last.company);
acum_count=0;
do until(last.industry);
set zhutou;
by company industry;
if not first.industry then do year1=prev_year+1 to year-1;
random_number = ranuni(12345);
output;
end;
acum_count = sum(acum_count, count);
year1 = year;
random_number = ranuni(12345);
output;
prev_year = year;
end;
do year1 = year+1 to last_year;
random_number = ranuni(12345);
output;
end;
end;
run;
[/code:3uagxwrw]
你只有几万行数据,不必担心冗余。
说来说去,问题还得靠你自己发现解决。[/quote:3uagxwrw] |
|