« String Matching | Main | Code Snippet Management Tools »

Cumulative Totals

Linda Adams writes a nice piece of SAS code to create a variable of Cumulative Totals.  It is reproduced below:

    data one;
    input pulldate MMDDYY10.
    tsippT 12-14
    tsippC 15-18
    count 20;
    format pulldate date7.;
    cards;
    08/04/2006 34 24 1
    09/25/2006 343 200 2
    10/20/2006 678 398 3
    11/03/2006 713 406 4
    02/07/2007 857 451 5
    ;
    run;

    proc sort data=one;
    by pulldate;
    run;

    data two;
    set one;
    by pulldate;
    if first.count then sumT=0;
    sumT+tsippT;
    if last.pulldate;
    run;

    proc print data=two;
    run;

Posted on Monday, March 31, 2008 by Registered CommenterJared | CommentsPost a Comment

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>