Hello all,
I would like to drop certain observations from my database and I am not sure how to do so.
My data consists of stock' ticker, dates, additional date variable, and a binary variable which equals 1 if the additional date variable is equal to the date under each ticker
for example:
Name Date date1 binary
apple 01jan2010 . 0
apple 02jan2010 02jan2010 1
apple 03jan2010 . 0
google 01jan2010 . 0
google 02jan2010 . 0
google 03jan2010 03jan2010 1
tesla 01jan2010 . 0
tesla 02jan2010 . 0
tesla 03jan2010 . 0
I would like to drop every stock that has no date1 (or binary=1) observations, so in the case of my example, that would mean drop all the observations of tesla.
Note: I would like to keep the observations of the other stocks, even though some of them do not coincide with date1.
additional note: 1 observation is enough to keep the stock in the dataset.
result:
Name Date date1 binary
apple 01jan2010 . 0
apple 02jan2010 02jan2010 1
apple 03jan2010 . 0
google 01jan2010 . 0
google 02jan2010 . 0
google 03jan2010 03jan2010 1
Thank you all!
Related Posts with dropping observation with a con
Collapsing with class numerosity as weightDear Statalist, I am working with a large dataset (30 mln obs, 1979-2018) and would like to collaps…
Solvenl - Optimize for 2 unknown variables (in Mata)Hi all, i try to solve the Black-Scholes-Merton formula for two unknwons: Asset Value & Asset Vo…
Fama and French industry classificationsDear Stata users, I have been struggling to convert my sic code into the 12 industries classified b…
How to erase multiple graphs from file?Hello I am generating several charts but would like to delete after graph combine. I have tried th…
Save a variable name as macro conditional on somethingHello everyone, I have a data set with 5 indicators. I would like to save as a macro, for each "clu…
Subscribe to:
Post Comments (Atom)
0 Response to dropping observation with a con
Post a Comment