Hi!
Excuse me, but my English is not very good
I hope you understand the question
I have the following data table:
Table_A
| Station | equipment | volume |
| ST_a | eq_a_1 | 10 |
| ST_a | eq_a_2 | 9 |
| ST_a | eq_a_3 | 5 |
| ST_b | eq_b_1 | 10 |
| ST_b | eq_b_2 | 3 |
| ST_c | eq_c_1 | 15 |
| ST_c | eq_c_2 | 14 |
I need to accumulate the value of the Volume column and keep all the records so that the result is shown as the following table
| Table_B | |||
| Station | equipment | volume | cumulative |
| ST_a | eq_a_1 | 10 | 10 |
| ST_a | eq_a_2 | 9 | 19 |
| ST_a | eq_a_3 | 5 | 24 |
| ST_b | eq_b_1 | 10 | 10 |
| ST_b | eq_b_2 | 3 | 13 |
| ST_c | eq_c_1 | 15 | 15 |
| ST_c | eq_c_2 | 14 | 29 |
I really need to solve this problem.
Thank you very much!
cumulative+volume;
run;
reset cumulative to zero when reading a new by group
Thanks
data have;
input Station $ equipment $ volume;
cards;
ST_a eq_a_1 10
ST_a eq_a_2 9
ST_a eq_a_3 5
ST_b eq_b_1 10
ST_b eq_b_2 3
ST_c eq_c_1 15
ST_c eq_c_2 14
;
data want;
set have;
by Station equipment;
if first.Station then cumu=volume;
else cumu+volume;
/*if last.Station;*/
run;
Try
by descending Station descending equipment;
Thank you very much!!!!! it worked perfectly!!
Welcome to the SAS forum and I hope you have fun. Take care!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.