Hello, sorry if the title is not clear! A small sample of my data can be seen below. My aim is to delete all rows from a certain company (TICKER) if they do not have observations from all years 2010-2020. For example, in the data below, I would keep all the rows for ticker A, however since AAA and AAAP only have data for some years I would want to drop all the rows for those tickers. I have tried to play around with the DROP IF function however I am new to Stata so I'm also having difficulties finding search terms for help on what I'm looking for. Sorry since this has probably been answered previously.
Code:
TICKER year RET
A 2010 .360587924
A 2011 -.105289804
A 2012 .200218003
A 2013 .368424385
A 2014 .002363122
A 2015 .065968707
A 2016 .119250455
A 2017 .40943002
A 2018 .040816839
A 2019 .279583614
A 2020 .367221266
AA 2010 .055579704
AA 2011 -.490790864
AA 2012 .041280666
AA 2013 .237985016
AA 2014 .427898743
AA 2015 -.425617623
AA 2016 .055984234
AA 2017 .764060466
AA 2018 -.64663515
AA 2019 -.139412225
AA 2020 .646594437
AAA 2020 .007631533
AAAP 2015 .182677761
AAAP 2016 -.033216692
AAAP 2017 1.2492474
AAAP 2018 -.014702334
0 Response to Remove rows if variable value does not have a certain amount of observations
Post a Comment