how to add 2 column with respect of group : <p>I want to add column a and b separately sum.a and sum.b with respect of group SAMPN</p>

<p>Output:</p>

<pre><code>SAMPN     a   b
 1        1   2
 1        3   5
 2        1   1
 2        7   4
</code></pre>

<p>output</p>

<pre><code>SAMPN     a   b     sum.a       sum.b
 1        1   2      4            7
 1        3   5      4            7
 2        1   1      8            5
 2        7   4      8            5
</code></pre>
