Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: How to calculate cross-subgroup values within the same variable?
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: How to calculate cross-subgroup values within the same variable?
Date
Thu, 7 Jul 2011 15:38:23 +0100
This is an FAQ.
FAQ . . Creating variables recording prop. of the other members of a group
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
4/05 How do I create variables summarizing for each
individual properties of the other members of a
group?
http://www.stata.com/support/faqs/data/members.html
Nick
[email protected]
Yao Amber LI
I am trying to calculate a cumulative distance between each local firm
and all other foreign firms within the same industry each year.
My data structure is as follows (for each year and each industry).
Firm_ID ownership latitude longitude
1 local
2 local
3 local
4 local
5 local
... local
I local
1 foreign
2 foreign
3 foreign
... foreign
J foreign
To sum up, in each industry each year, I have a group of local firms
with their latitude and longitude; and a group of foreign firms with
their latitude and longitude.
I need to calculate a cumulative distance between each local firm (i)
and all other foreign firms in that industry the same year. The
distance formula will be Dist_i = sum_{j} function(d_{ij}), where
i=1,..., I; and j=1,..., J. And d_{ij} is a function of latitude_{i},
longitude_{i} and all other FOREIGN firms' latitude and longitude.
How should I achieve that object? How can I loop over each local firm
with all other foreign firms?
Any help would be appreciated. Thanks!
All my best,
Amber
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/