Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: counting number of stores per brand at a certain distance


From   Fernando Luco <flucoestatalist@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: counting number of stores per brand at a certain distance
Date   Wed, 27 Feb 2013 16:05:44 -0600

Hi,

I have a data set with a lot of stores (identified by id and brand)
and I would like to compute the number of stores (and brands) that
each store has at 2 or less kilometers. The data looks as follows

id brand d_1 d_2 d_3
1 c 1 1 0 0
2 s 1 1 0 1
3 t 0 0 1 1
4 s 0 1 1 1

The example says that stores in the pairs (1,2), (2,4) and (3,4) are
closer than 2 kms of each other.

I would like to create three columns, one for each brand, having the
number of stores of each brand. In the example this should look like

id brand d_1 d_2 d_3 n_c n_s n_t
1 c 1 1 0 0 0 1 0
2 s 1 1 0 1 1 1 0
3 t 0 0 1 1 0 1 0
4 s 0 1 1 1 0 1 1

Any ideas on how to do this? Note that because of the way the data is
presented, all stores are at less than 2 kms of themselves so when
counting the number of rivals of each brand I need to take this in
consideration.

Thanks,

Fernando
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index