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
Coefplot for coefficient of various estimatesThe following code is supposed to create a graph ( like the attached one here ) but unfortunately, I…
How to use the egen command and not set missing to zeroHi Statalist, I am using the egen rowlast command to tell me the depression scores for patients in …
Add missing valuesHello, I have the following dataset: Code: * Example generated by -dataex-. To install: ssc inst…
create utf-8 xml file with tabmultHi everyone, I create a .xml file with various sheets which I later on open in Excel. One sheet has…
How to run a regression using weight by the number of children to each parentDear all, I want to examine the effects of children' s characteristics on their parent health outco…
Subscribe to:
Post Comments (Atom)
0 Response to Help with calculations based on conditions and groups
Post a Comment