I have one macro which CSUMs up one variable in one dataset. It runs fine. But the issue is the data is huge with lots of variables
waiting for same CSUM process. If process one variable, it is far away from being efficient.
How to process in a systematic way? Once for all variables? Say %let varlist=var1, var2, var3, ..., var100;
If var1/2/3/.../100, read in as 100 rows in a temp dataset, then generate the code in a systematic way. I can do that.
The quest is then that how to turn the varlist into a dataset(one variable name for one row)?!
Thanks,
%macro cumsum1by(ds, var, byvar); data &ds.(DROP = ); /*data &ds.(DROP = );*/ set &ds.; by &byvar.; RETAIN &var._csum ; &var._csum=coalesce(&var.,0)+coalesce(&var._csum,0) ; IF FIRST.&byvar. THEN &var._csum = coalesce(&var.,0) ; RUN ;quit; %mend;
... View more