Hi,
I work on unbalanced panel data (26 states ("cant"), time period around 1970-2017) on wealth shares ("P90"). I want to generate a new variable that measures for each state the overall change in P90 from the last to the first observation (over time). Look at the excerpt from my dataset for an example:
For cant=1, I want to create a variable that is equal to: 0.755419 – 0.7490362
Note that the dataset doesn't include the same first year for all cantons. The first observation for cant=1 is 1975. For cant=2, it is 1977.
How do I create such a variable for all 26 states?
Thanks!
input float cant double year float P90
1 1975 .7490362
1 1981 .7319754
1 1983 .7209229
1 1987 .7390646
1 1991 .724773
1 1995 .7064956
1 1999 .7529215
1 2003 .734058
1 2004 .7299312
1 2005 .7453706
1 2006 .7487444
1 2007 .7550854
1 2008 .7425138
1 2009 .7330889
1 2010 .7377599
1 2011 .7376866
1 2012 .741205
1 2013 .742767
1 2014 .7461374
1 2015 .7498978
1 2016 .7495821
1 2017 .755419
2 1977 .6740181
2 1981 .6523791
2 1991 .6468652
2 1997 .6702179
2 2003 .6489691
2 2004 .6559614
2 2005 .6677032
2 2006 .6725178
2 2007 .6955403
2 2008 .6790535
2 2009 .6876738
2 2010 .6895582
2 2011 .6878965
2 2012 .6927519
2 2013 .6989366
2 2014 .6949768
2 2015 .7029172
2 2016 .7052284
2 2017 .7107742
3 1973 .743027
3 1981 .6784297
3 1983 .672592
3 1991 .7058665
3 1993 .714372
3 1995 .6840838
3 1997 .7190968
3 1999 .7196878
3 2003 .7256334
3 2004 .7265204
3 2005 .7271922
3 2006 .7188094
3 2007 .7376335
3 2008 .7220148
3 2009 .7229825
3 2010 .7288389
3 2011 .7396641
3 2012 .7448026
3 2013 .7533194
3 2014 .758797
3 2015 .7646412
3 2016 .7693793
3 2017 .769841
4 1981 .6057187
4 1991 .6259277
4 1997 .57855046
4 2003 .51805264
4 2004 .53431404
4 2005 .53986645
4 2006 .545574
4 2007 .55528235
4 2008 .5523054
4 2009 .5599864
4 2010 .56871885
4 2011 .52957606
4 2012 .54068273
4 2013 .54666424
4 2014 .5533657
4 2015 .55440116
4 2016 .56613487
4 2017 .5771765
5 1979 .685352
5 1981 .33659706
5 1983 .3615786
5 1985 .3325868
5 1987 .3805338
5 1989 .4322503
5 1991 .4656941
5 1993 .4792115
5 1995 .5525481
5 1997 .6400445
5 1999 .7036961
5 2001 .7184193
5 2002 .6966427
5 2003 .8024087
5 2004 .7394421
5 2005 .7702557
5 2006 .7694538
5 2007 .8118458
end
format %ty year
[/CODE]
Related Posts with Panel data: Calculate change within each subgroup from the first to the last observation (over time)
Data management problemHi I am trying to analyze some data, and have entered some commands,..as reproduced below,..however…
Command stir does not accept iweightsHello I've been using the command stir (incidence rate comparison). The manual says that stir allows…
Replace if not found within a loopDear all, I am trying to bottom and top coding the household income for each country - wave. I am us…
ci for categorial variables - tabci?I'm just wondering why Stata gives CIs for binary variables - ci proportions varname - but, as far a…
.. …
Subscribe to:
Post Comments (Atom)
0 Response to Panel data: Calculate change within each subgroup from the first to the last observation (over time)
Post a Comment