BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BCNAV
Quartz | Level 8

I have data like:

 

Day    Current    Previous    Growth

1      10          5          1.0

2      20         10          1.0

3      30                    15          1.0

etc.

 

I would like to add another variable that creates a running total (RT) and running growth rate:

 

Day    Current    Previous    Growth    RT_Curr  RT_Prev   RT_Growth 

1      10          5          1.0       10        5        1.0

2      20         10          1.0       30       15        1.0

3      30                    15          1.0       60       30        1.0

etc.

 

Is there an easy way to do this in SAS?  Datastep?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
BCNAV
Quartz | Level 8

Totally forgot about that !!!  Thx!

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I can't determine from your example how running total growth is computed. Nevertheless, running totals are simple.

 

data want;
    set have;
    rt_curr+current;
    rt_prev+previous;
run;
--
Paige Miller
BCNAV
Quartz | Level 8

Totally forgot about that !!!  Thx!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 831 views
  • 0 likes
  • 2 in conversation