Dear Colleagues,
I am struggling in my panel dataset to calculate variables reflecting differences in means over different time periods.
I have my ID (ICO) and YEAR (ROK) continuous outcome variables, and I need to calculate a new variable reflecting the differences in the mean values of years (2013-2018) and mean values of years (2007-2012).
I tried to use the following codes, but they did not work well - the differences in my mean outcome variables (ROA) provide empty values because there are different time windows. Any clue how to overcome this problem?
Thanks a lot for your help and suggestions,
Ondřej
bys ICO: egen ROA_1318 = mean(ROA) if inrange(ROK,2013,2018)
by ICO: egen ROA_1318 = mean(ROA) if ROK > 2012 & ROK < 2019
by ICO: egen ROA_0812 = mean(ROA) if ROK > 2007 & ROK < 2013
gen ROA_DIF = ROA_1318 - ROA_0812
egen ROA_DIF = rowtotal(ROA_1318 ROA_0812_m)
replace ROA_DIF = . if ROA_DIF==0
bys ICO: egen ROA_1318 = mean(ROA) if inrange(ROK,2013,2018)
bys ICO: egen ROA_0812 = mean(ROA) if inrange(ROK,2007,2012)
by ICO: gen ROA_DIF = ROA_1318 - ROA_0812
Example of my panel data structure (continuous variables missing)...
ROK Sektor ICO NAZEV CONTINUOUS VARIABLES .....
2003 2 205 Vojenské lesy a statky ČR, s.p.
2004 2 205 Vojenské lesy a statky ČR, s.p.
2005 2 205 Vojenské lesy a statky ČR, s.p.
2006 2 205 Vojenské lesy a statky ČR, s.p.
2007 2 205 Vojenské lesy a statky ČR, s.p.
2008 2 205 Vojenské lesy a statky ČR, s.p.
2009 2 205 Vojenské lesy a statky ČR, s.p.
2010 2 205 Vojenské lesy a statky ČR, s.p.
I am struggling in my panel dataset to calculate variables reflecting differences in means over different time periods.
I have my ID (ICO) and YEAR (ROK) continuous outcome variables, and I need to calculate a new variable reflecting the differences in the mean values of years (2013-2018) and mean values of years (2007-2012).
I tried to use the following codes, but they did not work well - the differences in my mean outcome variables (ROA) provide empty values because there are different time windows. Any clue how to overcome this problem?
Thanks a lot for your help and suggestions,
Ondřej
bys ICO: egen ROA_1318 = mean(ROA) if inrange(ROK,2013,2018)
by ICO: egen ROA_1318 = mean(ROA) if ROK > 2012 & ROK < 2019
by ICO: egen ROA_0812 = mean(ROA) if ROK > 2007 & ROK < 2013
gen ROA_DIF = ROA_1318 - ROA_0812
egen ROA_DIF = rowtotal(ROA_1318 ROA_0812_m)
replace ROA_DIF = . if ROA_DIF==0
bys ICO: egen ROA_1318 = mean(ROA) if inrange(ROK,2013,2018)
bys ICO: egen ROA_0812 = mean(ROA) if inrange(ROK,2007,2012)
by ICO: gen ROA_DIF = ROA_1318 - ROA_0812
Example of my panel data structure (continuous variables missing)...
ROK Sektor ICO NAZEV CONTINUOUS VARIABLES .....
2003 2 205 Vojenské lesy a statky ČR, s.p.
2004 2 205 Vojenské lesy a statky ČR, s.p.
2005 2 205 Vojenské lesy a statky ČR, s.p.
2006 2 205 Vojenské lesy a statky ČR, s.p.
2007 2 205 Vojenské lesy a statky ČR, s.p.
2008 2 205 Vojenské lesy a statky ČR, s.p.
2009 2 205 Vojenské lesy a statky ČR, s.p.
2010 2 205 Vojenské lesy a statky ČR, s.p.

Comment