07-24-2015 04:58 AM
I need to capture a running_sum but unsure how to against the key_hedge and Dealt_amount.
Key_hedge and Dealt amount are in a table called static_summit.
Any ideas please?
07-24-2015 11:20 AM
This code doesn't seem to work. I have running_sum and dealt_amount all blank.
Maybe I wasn't too clear originally .
Key_hedge and Dealt_amount are vaiables im pulling in from a table Summit static.
Running_sum doesn't exist so im needing to create this variable. I have manually added the data within the running sum as to what it is i need to see but the code above doesn't do this.
07-24-2015 11:23 AM
I don;t see any reason why the code would not work, the data is sorted by key_hedge yes? And dealt amount is numeric yes? If so this should work:
if first.key_hedge then running_sum=dealt_amount;
else running_sum=sum(running_sum,dealt_amount); /* Maybe change to this also in case your first value is 0 */
If it doesn't please post test data - as a datastep - so I can test it.
07-24-2015 09:21 AM
Here you go, this is set up to start the running_sum as new for every new key_hedge, if that is not what you want you should remove the line that starts with 'if'.
infile cards dsd;
format Key_hedge $14. Dealt_amount comma10.;
input Key_hedge$ Dealt_amount;
format Key_hedge $14. Dealt_amount Running_sum comma10.;
if first.key_hedge then running_sum = 0;
running_sum + dealt_amount;