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'
Trust game and a new method to measure reciprocityI am working in with a Trust Game Experiment and someone suggest me that I can use an alternative me…
Changing a variable by a factor of 1000Hi, I have a float variable of birth weight in grams but there are approximately 250 entries which h…
Regressing panel data returns "repeated time values within panel"Hi somebody there. I am new to start and I am trying to regress panel data from a huge cohort that f…
rerun the code to count TFP and error continues to emerge as saying missing values in cluster variable __000002 not allowedHi, I am using almost the same code to count TFP, but it continues to saying" missing values in clus…
Help with -foreach loop commandHi, I am trying to simplify my code to generate and replace multiple variables. Below is the code t…
Subscribe to:
Post Comments (Atom)
0 Response to Counting observations with an 'if'
Post a Comment