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. As that dataset is fairly large, i have provided you a small sample. 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 - 1999 by multiplying the yearly growth numbers from - GrowthYear -. The variable that has to be created 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 1999. Therefore, i want to multiply the values from - Growthyear - where the number of companies within the same industry, in the same city and year to be smaller than 2 & whereas the variable - year - is smaller than 2000. The yearly growth number of the city is taken into the calculation only once. Finally, i want the value for the variable that has to be created to be equal for all companies across years and all industries that are located in the city for the period 1996-1999.
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:
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. As that dataset is fairly large, i have provided you a small sample. 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 - 1999 by multiplying the yearly growth numbers from - GrowthYear -. The variable that has to be created 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 1999. Therefore, i want to multiply the values from - Growthyear - where the number of companies within the same industry, in the same city and year to be smaller than 2 & whereas the variable - year - is smaller than 2000. The yearly growth number of the city is taken into the calculation only once. Finally, i want the value for the variable that has to be created to be equal for all companies across years and all industries that are located in the city for the period 1996-1999.
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:
HTML Code:
https://www.statalist.org/forums/forum/general-stata-discussion/general/75096-how-to-multiply-observations-within-a-variable-in-stata
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str26 city int year str2 Industry_code float(duplicate GrowthYear) "A" 1997 "1" 0 1.0365331 "A" 1997 "2" 1 1.0365331 "A" 1997 "2" 2 1.0365331 "A" 1997 "3" 0 1.0365331 "A" 1997 "4" 0 1.0365331 "A" 1997 "5" 1 1.0365331 "A" 1997 "5" 2 1.0365331 "A" 1998 "1" 0 .9852498 "A" 1998 "2" 1 .9852498 "A" 1998 "2" 2 .9852498 "A" 1998 "3" 0 .9852498 "A" 1998 "4" 0 .9852498 "A" 1999 "1" 0 1.0644425 "A" 1999 "2" 1 1.0644425 "A" 1999 "2" 2 1.0644425 "A" 1999 "3" 0 1.0644425 "A" 1999 "4" 0 1.0644425 "A" 1999 "5" 1 1.0644425 "A" 1999 "5" 2 1.0644425 "A" 1999 "6" 1 1.0644425 end
Kind regards,
Patrick
Comment