title: awk running total count and sum
body: <p>Would like to know how to calculate 80%-20% rule contribution of vendors on daily basis.</p>
  
  <p>Input.csv</p>
  
  <pre><code>Date,Region,Vendor,Amount
  5-Apr-15,east,cc,50
  5-Apr-15,east,dd,15
  5-Apr-15,south,bb,15
  5-Apr-15,south,aa,10
  7-Apr-15,east,cc,123
  7-Apr-15,south,bb,88
  7-Apr-15,south,aa,40
  7-Apr-15,west,ss,30
  7-Apr-15,west,rr,20
  </code></pre>
  
  <p>In the above input, based on $1 field need to populate Running Sum of Amount then calculate percentage of Running Sum of Amount for the day</p>
  
  <pre><code>Date,Region,Vendor,Amount,RunningSum,%RunningSum
  5-Apr-15,east,cc,50,50,56%   (RunningSum=50 , %RunningSum=50/90(Total Amount for the day) 
  5-Apr-15,east,dd,15,65,72%   (RunningSum=50+15, %RunningSum=65/90)
  5-Apr-15,south,bb,15,80,89%  (RunningSum=65+15, %RunningSum=80/90)
  5-Apr-15,south,aa,10,90,100% (RunningSum=80+10, %RunningSum=90/90)
  </code></pre>
  
  <p>Once it is derived 80% or first hit of 80%above need to consider as 80% contribution remaining line items need to be consider as 20% contribution.</p>
  
  <p>Expected Output:</p>
  
  <pre><code>Date,Countof80%Vendor, SumOf80%Vendor, Countof20%Vendor, SumOf20%Vendor
  5-Apr-15,3,80,1,10
  7-Apr-15,3,251,2,50
  </code></pre>
  
  <p>Any suggestions ...</p>