Hello everyone,
Below, you will find a structure of a similar dataset that i am using. The data consists of all companies present in a given year for the period 1996-2015. Also the company's industry code is known, as well as the city's yearly growth. I am trying to generate the total growth of a city between 1996 - 1998 by multiplying the yearly growth numbers from - GrowthYear -. This will be put in the variable - Growth1996_1998 -. The variable - Growth1996_1998 - will thus be the same all observations that have the same city where the years fall between 1996-1999. Obviously, i can not multiply every value found in the -GrowthYear - variable, as this will lead to an overestimation of the growth between 1996 and 1998. Therefore, i want to multiply the values from - Growthyear - where - CompanyNumber - < 2 & - Year - < 1999 so that each yearly growth number is represented only once in the end result. Finally, i want the value for -Growth1996_1998- to be equal for all companies across years and all industries that are located in the city for the period 1996-1998. This is represented as the Xs, Ys, and "." found in the dataset under - Growth1996_1998 -
I have found the code suggested in a similar, but easier example (see link below). Unfortunately, this did not work for my database.
I hope that someone can help me out. Feel free to ask any question.
Kind regards,
Patrick
Below, you will find a structure of a similar dataset that i am using. The data consists of all companies present in a given year for the period 1996-2015. Also the company's industry code is known, as well as the city's yearly growth. I am trying to generate the total growth of a city between 1996 - 1998 by multiplying the yearly growth numbers from - GrowthYear -. This will be put in the variable - Growth1996_1998 -. The variable - Growth1996_1998 - will thus be the same all observations that have the same city where the years fall between 1996-1999. Obviously, i can not multiply every value found in the -GrowthYear - variable, as this will lead to an overestimation of the growth between 1996 and 1998. Therefore, i want to multiply the values from - Growthyear - where - CompanyNumber - < 2 & - Year - < 1999 so that each yearly growth number is represented only once in the end result. Finally, i want the value for -Growth1996_1998- to be equal for all companies across years and all industries that are located in the city for the period 1996-1998. This is represented as the Xs, Ys, and "." found in the dataset under - Growth1996_1998 -
I have found the code suggested in a similar, but easier example (see link below). Unfortunately, this did not work for my database.
HTML Code:
https://www.statalist.org/forums/forum/general-stata-discussion/general/75096-how-to-multiply-observations-within-a-variable-in-stata
City | Year | Industry_code | CompanyNumber | GrowthYear | Growth1996_1998 |
A | 1996 | 1 | 1 | 1.025 | X |
A | 1996 | 1 | 2 | 1.025 | X |
A | 1996 | 1 | 3 | 1.025 | X |
A | 1996 | 2 | 1 | 1.025 | X |
A | 1996 | 2 | 2 | 1.025 | X |
A | 1997 | 1 | 1 | 0.98 | X |
A | 1997 | 1 | 2 | 0.98 | X |
A | 1997 | 1 | 3 | 0.98 | X |
A | 1997 | 1 | 4 | 0.98 | X |
A | 1997 | 2 | 1 | 0.98 | X |
A | 1997 | 2 | 2 | 0.98 | X |
A | 1997 | 3 | 1 | 0.98 | X |
A | 1997 | 3 | 2 | 0.98 | X |
A | 1997 | 3 | 3 | 0.98 | X |
A | 1998 | 1 | 1 | 1.02 | X |
A | 1998 | 2 | 1 | 1.02 | X |
B | 1996 | 1 | 1 | 1.01 | Y |
B | 1996 | 2 | 1 | 1.01 | Y |
B | 1996 | 3 | 1 | 1.01 | Y |
B | 1996 | 3 | 2 | 1.01 | Y |
B | 1997 | 1 | 1 | 1.03 | Y |
B | 1997 | 1 | 1 | 1.03 | Y |
B | 1997 | 2 | 2 | 1.03 | Y |
B | 1997 | 2 | 2 | 1.03 | Y |
B | 1998 | 1 | 1 | 1.10 | Y |
B | 1998 | 2 | 1 | 1.10 | Y |
B | 1998 | 2 | 2 | 1.10 | Y |
B | 1999 | 1 | 1 | 0.95 | . |
B | 1999 | 2 | 1 | 0.95 | . |
Kind regards,
Patrick