Hello all,
I have a dataset that looks something like this (but with over 70k observations and over 200 firms)
FirmID Area dummy
1 10 1
1 10 1
1 11 1
1 11 1
1 12 0
2 10 1
2 11 0
3 10 1
3 11 1
3 11 1
3 12 1
3 12 1
3 13 0
Each row represents a customer of the firm in that area. And the dummy reflects whether this area is part of the firm's market or not. Now using this data, I want to calculate the total number of customers (including those from other firms) belonging to all areas that constitute a market for a firm, which I am able to do using -by sort- and -egen-. However, after that, or each firm, I want to identify the firms for the customers (and the corresponding number of customers from these firms) in that firm's market. I'm wondering what's a quick way to do this in Stata/
Thank you in advance for any ideas here. And I'm happy to answer any questions if my ask isn't clear!
Related Posts with Help with calculations based on conditions and groups
creating quarter of birth dummyHow can i create a quarter of birth dummy with a variable expressed as 01jan1999 ? thank you …
Count the number of different values (ignoring missing)Hello everyone, I want to count the number of different values ignoring missing by pid. Code: * E…
adding a legend for xlineHello, I am trying something like below to add a legend for the green vertical xline that I added o…
Using Constraints with Movestay commandI want to test Lr test for endogenous switching regression equation (I have used movestay of this), …
Year and industry fixed effectsHi guys, In my regression model, I need to control for year and industry fixed effects. However, I'…
Subscribe to:
Post Comments (Atom)
0 Response to Help with calculations based on conditions and groups
Post a Comment