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!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: