r/stata•
ZayuhTheIV

Help with generating a new var that is the sum of a variable

Hi All,

​

I am looking at collapsed data and I have variable A that is a string, and variable B that is numeric. I would like to generate variable C as the sum of variable B.

​

I have used gen C=sum(B) but that is giving me running cumulative results. I just want the maximum number at the very bottom of this cumulative result. In other words, if the sum of variable B is 100, I want variable C to be 100 all the way down. I plan on creating variable D that is B divided by C to find percentages. Any help would be appreciated.

​

Thanks!

Posted Apr 9, 2019, 9:32 PM UTC

112
Loading comments…