Creating an industry median variable
Posted: Wed May 14, 2014 4:23 am
Hi,
I have a panel in which I want to generate a new series.
I have firm IDs as cross-sections, the panel is dated annualy.
The panel looks appx. like this (of course more observations and years in the actual panel):
ID YEAR INDUSTRY LEVERAGE MEDIAN LEVERAGE
1 2010 63 0.5 0.4
1 2011 63 0.6 0.5
2 2010 55 0.4 0.3
2 2011 55 0.3 0.3
3 2010 63 0.3 0.4
3 2011 63 0.3 0.5
... ... ... ... ...
What I want is a new series that shows the median leverage of a certain industry for each year.
For example, the median leverage in industry 63 in year 2010 could be 0.4. Then I each cross-section of industry 63 in year 2010 to be assigned this value in the MEDIAN LEVERAGE series.
How do I do that?
Thanks!
I have a panel in which I want to generate a new series.
I have firm IDs as cross-sections, the panel is dated annualy.
The panel looks appx. like this (of course more observations and years in the actual panel):
ID YEAR INDUSTRY LEVERAGE MEDIAN LEVERAGE
1 2010 63 0.5 0.4
1 2011 63 0.6 0.5
2 2010 55 0.4 0.3
2 2011 55 0.3 0.3
3 2010 63 0.3 0.4
3 2011 63 0.3 0.5
... ... ... ... ...
What I want is a new series that shows the median leverage of a certain industry for each year.
For example, the median leverage in industry 63 in year 2010 could be 0.4. Then I each cross-section of industry 63 in year 2010 to be assigned this value in the MEDIAN LEVERAGE series.
How do I do that?
Thanks!