![]() I prefer to use runby (from SSC) to process commands by groups. I'm also going to assume that stores that are more than 50km away are not suitable neighbors.įinding neighbors by group can require a fair amount of data management gymnastics. That may still be too large of a problem so I would recommend using geonear (from SSC) to find the nearest stores. For any given birth year, there is a sample of stores in operation that year so the task can be reduced to forming all pairwise combinations of individuals to stores in that birth year. The natural choice in this case is to do it by birth year. Save "store.dta", replaceThe real data may be too large to form all pairwise combinations of individuals/stores but you can do in parts. Gen strclose = stryr + runiformint(0,50) if runiform() <. Geodist lat1 lon1 lat2 lon2, generate(dist) I would appreciate if someone can help me. I want to do it for all individuals and then keep for each individual the nearest two supermarket branches. ![]() For the individual with year of birth 1955, I want to calculate the distance to the 7 supermarket branches operating in 1955. Now, in this example, individual 1 with year of birth 1952 does not have any supermarket branch operating in that year so I want the distance to be (.). ![]() Merge 1:1 _n using "individual.dta", nogen I know the format of geodist and geonear but I don't know how to loop it for each individuals year of birth to each supermarket's branch year. ![]() I need to calculate distance between the house of each individual to all the supermarket branches operating on the year of birth of that individual. I have a dataset with individuals with their geocoordinates and supermarket branches with geocoordinates. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |