I want to create columns that sum up values along each column of the table according to their Invested type (EUR/CHF/USD/...). I was about to use the following code:
then I supposed to see a column "Year2001" with many dublicated values, I would remove these dublicate values:
to have a column with expected values.
But the code just gave me a column just exactly the same as column G. I do not know why and how to fix it.
Also, I tried to use a loop to do this procedure for the variables H, I, J,... but I refered to some threads and it seems to me that I only can do if my variables are from A, B, C,...
Many thanks for your help.
I hope my pic attached is fine.
Code:
bysort id Invested: egen float Year2001 = total(G) order Year2001, after(G)
Code:
sort Invested Year2001 by Invested Year2001: gen dup = cond(_N==1,0,_n) drop if dup>1
But the code just gave me a column just exactly the same as column G. I do not know why and how to fix it.
Also, I tried to use a loop to do this procedure for the variables H, I, J,... but I refered to some threads and it seems to me that I only can do if my variables are from A, B, C,...
Many thanks for your help.
I hope my pic attached is fine.
Comment