Hello all,
For a large sample of firms, I need to count the number of (1) business segments and (2) geographic segments the business is in for the years 2010-2019. Using Ben Earnhart's code (https://www.statalist.org/forums/for...variable-group); bysort fyear CUSIP: gen howmany=_N gives me the number of segments for every firm in a particular year.
Now this is good, but I have to separate the business segments from the geographic segments.
For a particular firm, this is what it looks like:
SegmentType CompanyName fyear howmany
GEOSEG NEW SOURCE ENERGY PRTRS LP 2013 7
GEOSEG NEW SOURCE ENERGY PRTRS LP 2013 7
BUSSEG NEW SOURCE ENERGY PRTRS LP 2013 7
BUSSEG NEW SOURCE ENERGY PRTRS LP 2013 7
GEOSEG NEW SOURCE ENERGY PRTRS LP 2013 7
BUSSEG NEW SOURCE ENERGY PRTRS LP 2013 7
BUSSEG NEW SOURCE ENERGY PRTRS LP 2013 7
GEOSEG NEW SOURCE ENERGY PRTRS LP 2014 8
BUSSEG NEW SOURCE ENERGY PRTRS LP 2014 8
GEOSEG NEW SOURCE ENERGY PRTRS LP 2014 8
GEOSEG NEW SOURCE ENERGY PRTRS LP 2014 8
BUSSEG NEW SOURCE ENERGY PRTRS LP 2014 8
BUSSEG NEW SOURCE ENERGY PRTRS LP 2014 8
BUSSEG NEW SOURCE ENERGY PRTRS LP 2014 8
BUSSEG NEW SOURCE ENERGY PRTRS LP 2014 8
Anyone knows how to distinguish in the code between the two types of segments?
Related Posts with Counting observations with an 'if'
Need help:marginal problem of fmlogitHi I used this code to estimated average marginal effect after fmlogit fmlogit governing safety edu…
Estimate parameters from restrictions on regression parameters via GMMDear all, I am trying to replicate the market resiliency model used in the following paper: Bessemb…
Fixed effects code in a regressionDear Everyone, I would like to know if my code is correct. I am doing a regression (DiD) where I ha…
Merging databasesHi there, I really appreciate any help you can offer me. Basically I have a relational database iss…
Missing categories in newly created categorical variableHi Statalist. I have found that after creating a new categorical variable that not all categories a…
Subscribe to:
Post Comments (Atom)
0 Response to Counting observations with an 'if'
Post a Comment