New variable equals cumulative totals by id
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | *(Q) How can I calculate 1) cumulative totals and 2) cumulative totals by id. *(A) By Ray 2002/04/13. * http://pages.infinit.net/rlevesqu/index.htm DATA LIST LIST /patid count. BEGIN DATA 3002 12 3002 11 3002 12 3003 3 3003 4 3003 3 END DATA. * To create a cumulative sum. CREATE cumul=CSUM(count). * To get a running total 'cumul' by group (patid). SORT CASES BY patid. SPLIT FILE BY patid. CREATE cumul2=CSUM(count). |
Related pages
...