Dear All
Will appreciate if you can help me on the following query.
The following data shows firms (ID), year , reform year (SSRCOMPLETEYR) and the variable NTS (ownership proportion).
I want to create variables, i.e. the mean and median of NTS with respect to the reform year. For instance, for firms which have reform year (SSRCOMPLETEYR) 2005, then I want the mean and median values of NTS for all these firms for three-years prior (2002), two-years prior(2003) and one-year prior (2004) to the reform year (2005). I also want the mean and median values of NTS for all these firms t+1, t+2 and t+3 where t is the reform year (SSRCOMPLETEYR).
* Example generated by -dataex-. To install: ssc install dataex
clear
input long ID float YEAR int SSRCOMPLETEYR float NTS
2 2003 2005 .1583336
2 2004 2005 .14580873
2 2005 2005 .13422763
2 2006 2005 .129922
2 2007 2005 .02426268
2 2008 2005 .026378496
2 2009 2005 .002197306
2 2010 2005 .0017612013
2 2011 2005 .0016758556
2 2012 2005 .001673647
2 2013 2005 .0021632616
2 2014 2005 .0014382304
4 2014 2006 .001205394
6 2003 2006 .37771195
6 2004 2006 .37771195
6 2005 2006 .37771195
6 2006 2006 .2533447
6 2007 2006 .13797276
6 2008 2006 .08924162
6 2009 2006 .02732855
6 2010 2006 .02611745
6 2011 2006 .021394266
6 2012 2006 .01581895
6 2013 2006 .0087063005
6 2014 2006 .008220699
Many thanks
Yahya Ghazali
Related Posts with Average and Median values by group
Problem with capture confirm and graph combine Hello. I have problems combining two graphs in a loop . I do not have all of the combination …
Drop if - variable not foundHi all, Just a very simple question and command yet I can't figure out why it is not working. I ju…
How to use Stata commands to calculate the total score of Likert Scale questions?In order to assess the attitude about antibiotic use, there are 6 questions with 5 levels of respons…
Creating variables with a sequence of numbers based on whether other variables stay the same (for case:control matching)Hello everyone. This is my first time posting here, and I do so because I haven't been able to find…
Manipulating datatimeHi all, my dataset is like that: id data time 1 01jan2018 1 01jan2018 1 03jan2018 1 03jan2018 1 03j…
Subscribe to:
Post Comments (Atom)
0 Response to Average and Median values by group
Post a Comment