Dear Stata users,
I would like your help for the following problem. I have a data set with 22 countries and 20 years and a variable Total Assets (TA). Below you can see an example of the data base.
I would like to make a loop to create variables that show the Total Assets of the entire country per year, per country. So the data set would look like this.
Now I'm using the codes:
egen TM_A_1995 = sum(TA) if Country ==1 & Year == 1995
egen TM_A_1995 = sum(TA) if Country ==1 & Year == 1996
etc.
Can someone please help me with creating a loop?
Thank you in advance.
I would like your help for the following problem. I have a data set with 22 countries and 20 years and a variable Total Assets (TA). Below you can see an example of the data base.
I would like to make a loop to create variables that show the Total Assets of the entire country per year, per country. So the data set would look like this.
Now I'm using the codes:
egen TM_A_1995 = sum(TA) if Country ==1 & Year == 1995
egen TM_A_1995 = sum(TA) if Country ==1 & Year == 1996
etc.
Can someone please help me with creating a loop?
Thank you in advance.
Comment