Happy New Year, please accept:
You can use the STATA "xtset" command to spread out the length of the data, and then use the "xtsum" command to calculate the average. The specific steps are as follows:
1. Use the "xtset year city" command to set the data in long format, where year is the time variable and city is the prefecture-level city variable.
2. Run the "xtsum TFP" command to obtain the average value of TFP each year. 3. Use the "xtreg TFP year, fe" command to carry out fixed effect regression and get the TFP
Example:
Suppose that your data is stored in the variable "TFP", the time variable is "year", and the city variable is "city". You can follow these steps:
1. First, use the "xtset year city" command to set the data in a long format. This automatically creates some new variables, such as "panel variable: year(strongly balanced)" and "group variable: city(strongly balanced)".
2. Next, use the "xtsum TFP" command to find the average value of TFP for each prefecture-level city each year. This results in a new table containing information such as the average of TFPS for each year, the number of samples, and so on.
3. Then, perform fixed effect regression using the "xtreg TFP year, fe" command. So you can get the national TFP for each year.