Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Yao Amber LI <yaoamber@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: How to calculate cross-subgroup values within the same variable? |

Date |
Thu, 7 Jul 2011 22:30:34 +0800 |

Dear Statalisters, 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/

**Follow-Ups**:**st: RE: How to calculate cross-subgroup values within the same variable?***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: RE: Recording episodes** - Next by Date:
**Re: st: RE: how can I create deciles by group?** - Previous by thread:
**st: Transferring non real matrice from Mata to Stata.** - Next by thread:
**st: RE: How to calculate cross-subgroup values within the same variable?** - Index(es):