Hi,
Below is a part of my sample. Note that i and j refers to Co_ids (Company ids) and that each Co_id belongs into a single Sh_id (Shareholder).
Year Co_id Tax TA Sh_id
2004 A .4 12 1
2004 B .5 11 1
2004 C .2 2 1
2004 D .4 5 2
2004 E .6 7 2
2003 A .3 9 1
2003 B .1 . 1
2003 C .4 1 1
2003 D .7 8 2
2003 E .6 9 2
I need to create two variables for each Co_id {A, B, C, D and E):
The 1st one should equal to r(i)=TA(i)/[SumTAs], where i=A, B, C, D and E. Hence, Co_id(A) should be equal to 12/(12+11+2) for year 2004 and "." because one of the Co_ids owned by the same Sh_id has a missing value in each TA.
The 2nd veriable is much more involved. I want to create a variable that is equal to:
the Sum(across j) of [Tax(i)-Tax(j)]r(j). For 2004 and Co_id A should be:
[Tax(A)-Tax(B)]*r(B)+[Tax(A)-Tax(C)]*r(C)=[0.4-0.5]*r(B)+[0.4-0.2]*r(C). For B it should be [0.5-0.4]*r(A)+[0.5-0.2]*r(C). Similarly, this variable should give "." if one of the arguments for one of the Co_ids is not there.
Thank you very much.
Regards,
Socrates
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/