Hi, I am still quite new to Stata (using Stata 16) and hope to find help here as I do not know how to solve this problem.
I have panel data (S&P 500) for roughly 20 years and a plethora of sic2 industries.
What I want to do is fo a certain variable (e.g., experience) for each sic2-industry and each year find the top performers (top decentile) and then create a variable where this "benchmark" can be recorded to. So in the end each firm (even if not a top performer) has the top performer average of this sic2 and year to compare to using this benchmark variable. I am using weighted average by sales.
So my benchmark variable is price-cost margin:
gen pg_margin = (sale-(cogs+xsga))/sale
egen pg_deciles = xtile(pg_margin), by(fyear sic2) nq(10)
// now I can claim that every firm firm with a "10" in pg_deciles is a top performer
// I further generate a dummy variable for industry leader to mark them
gen industrylead_sic2 = 0 // set up variable
replace industrylead_sic2 = 1 if pg_deciles==10
gen industrylead_experience = 0 // I create a new variable for experience in industry leaders (the benchmark variable)
replace industrylead_experience = experience if industrylead_sic2 == 1 // I copy over the experience of only the industry leaders in the new variable
bysort fyear sic2: egen wtavgindustrylead_experience = wtmean(industrylead_experience), weight(sale) // create an avg industryleader group per year per SIC2 weighted by sales
I have two questions:
1. Is this the correct way to do this or am I missing something?
2. How do I exclude the focal firm itself from the industry leader group if it is a top performer itself? And do I even need to if I want to avid endogeneity?
Thank you!
Related Posts with Calculating averages (industry+year) based on sub sample and then applying them to all firms
graph bar with both exclude0 and stack - any way to both stack and control the y axis range?Hello Statalist, I'd like to use graph bar with both its exclude0 and stack options. In other words…
When to winsorize the dataHello everyone, for the first time I am working with variables that are aggregated at the country-y…
Regression designHello, I'm trying to run a regression to test whether firms’ capital structure changes more during t…
Dummy-Variable for half yearly observationsHello, my dataset contains half yearly data from 2000 - 2018 which is written as 2000h1 or 2000h2. …
Difference between two predictions after a log-linear regressionHello everyone, I am working on cross section data and I am trying to run a simulation of the impac…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating averages (industry+year) based on sub sample and then applying them to all firms
Post a Comment