I need to calculate the following. Generate variable “High” = 1 if median “inflation” over the past 5 years is higher than the median over the whole sample. For example, in the example below the median inflation for the sample is 15.5. For the year 2005 “High”=0 since median for the past 5 years (2000-2004) is less than the sample median (15.5). Basically, I don’t know how to calculate median of past 5 years inflation level for each year. Please, help me with this issue.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(gvkey fyear infl) 1 2000 10 1 2001 11 1 2002 12 1 2003 13 1 2004 14 1 2005 15 1 2006 16 1 2007 17 1 2008 18 1 2009 19 1 2010 20 1 2011 21 end
Comment