Bookmark and Share

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: counting number of stores per brand at a certain distance


From   Fernando Luco <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index