S*****A 发帖数: 44 | 1 What I want do is to cumulate the A until is great than 80% of sum.
proc new;
set new;
retain AS;
AS=AS+A ;
DO until ( AS>= .8*sum(A) );
end;
run;
but, it runs forever!!! I do not think it takes that long to just get the
cumulative sum.
Help me ~~~ | b******e 发帖数: 539 | 2 the do loop in SAS is not the same as in other languages
besides, what do you want to do after it accumulates to 80%
anyway, here is something you can do:
first, get the total of A:
proc sql noprint;
select sum(A) into :total_A from new;
quit;
then get a data set that contains obs with accumulated A <= 80%:
data new;
set new;
retain C 0;
c = c + a;
if c <= 0.8*&total_a then output;
run; |
|