Page 1 of 1

Creating an industry median variable

Posted: Wed May 14, 2014 4:23 am
by gerrard
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!

Re: Creating an industry median variable

Posted: Wed May 14, 2014 7:04 am
by startz

Code: Select all

series med = @mediansby(LEVERAGE ,@expand(industry,year))
might work. It's worth a try.

Re: Creating an industry median variable

Posted: Thu Jun 05, 2014 7:54 am
by gerrard
Hey,

thanks for your suggestion. Unfortunately, this doesn't work. What the command does is create the median leverage for industry with the code 1 and for year 2000.
I need the median for each industry, for each year.

The variable that the median should be taken of: LEV1
Name of the year variable: YEAR
Name of the industry variable: IND1

Anyone? Would be very grateful.

Thanks!

EDIT: I found out how to do it. It works if you enter

Code: Select all

med_lev1=@mediansby(lev1,ind1,year)

Re: Creating an industry median variable

Posted: Thu Jun 05, 2014 8:16 am
by EViews Gareth

Code: Select all

series med = @mediansby(lev1, ind1, year)