I need clarification about a few things that are written below. I have a daily stock price dataset from 01-07-2016 to 30-06-2018, i.e., 24 months. The first 12 months, i.e. 01-07-2016 to 30-06-2017 is for selecting of liquid stocks. The second 12 months, i.e. 01-07-2017 to 30-06-2018 is for estimation purpose. Using first 12 months of data, i want to drop stocks which do no meet a certain liquidity criteria, i.e., number of days of trade. Say, if a stock does not have at least 200 pr values during 01-07-2016 to 30-06-2017 should be dropped from the sample. Moreover, i need the number of stocks that are dropped using the given criteria. I tried using these few codes. Just want to confirm if they are rightly specified and if someone make them more precise. The data example is also appended.
The last command, i.e. drop need particular attention. What it should be to ensure that using nobs<=200 in year first, stocks have to be dropped in year second.
.
The last command, i.e. drop need particular attention. What it should be to ensure that using nobs<=200 in year first, stocks have to be dropped in year second.
Code:
//for generating no of observation per company per year bys stock_id : egen nobs= count(pr) if mdate<=ym(2017,6) //number of illiquid stocks filtered per month by stock_id: gen excl= _N if nobs<=200 & mdate<=ym(2017,6) //for dropping of illiquid stocks drop if nobs<=200
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float stock_id str52 stock int date float(mdate year) double pr 1 "20 Microns Ltd." 20636 678 2016 30.05 1 "20 Microns Ltd." 20639 678 2016 29.8 1 "20 Microns Ltd." 20640 678 2016 30.35 1 "20 Microns Ltd." 20642 678 2016 29.8 1 "20 Microns Ltd." 20643 678 2016 29.9 1 "20 Microns Ltd." 20646 678 2016 30 1 "20 Microns Ltd." 20647 678 2016 29.6 1 "20 Microns Ltd." 20648 678 2016 29.4 1 "20 Microns Ltd." 20649 678 2016 29.05 1 "20 Microns Ltd." 20650 678 2016 29.25 1 "20 Microns Ltd." 20653 678 2016 28.65 1 "20 Microns Ltd." 20654 678 2016 28.5 1 "20 Microns Ltd." 20655 678 2016 28.6 1 "20 Microns Ltd." 20656 678 2016 28.45 1 "20 Microns Ltd." 20657 678 2016 28.55 1 "20 Microns Ltd." 20660 678 2016 28.95 1 "20 Microns Ltd." 20661 678 2016 28.85 1 "20 Microns Ltd." 20662 678 2016 29.8 1 "20 Microns Ltd." 20663 678 2016 30.15 1 "20 Microns Ltd." 20664 678 2016 29.3 1 "20 Microns Ltd." 20667 679 2016 28.85 1 "20 Microns Ltd." 20668 679 2016 29.35 1 "20 Microns Ltd." 20669 679 2016 29.8 1 "20 Microns Ltd." 20670 679 2016 29.9 1 "20 Microns Ltd." 20671 679 2016 29.85 1 "20 Microns Ltd." 20674 679 2016 35.7 1 "20 Microns Ltd." 20675 679 2016 39 1 "20 Microns Ltd." 20676 679 2016 39.45 1 "20 Microns Ltd." 20677 679 2016 39.6 1 "20 Microns Ltd." 20678 679 2016 39.85 1 "20 Microns Ltd." 20682 679 2016 39.2 1 "20 Microns Ltd." 20683 679 2016 38.6 1 "20 Microns Ltd." 20684 679 2016 39.45 1 "20 Microns Ltd." 20685 679 2016 39.25 1 "20 Microns Ltd." 20688 679 2016 39.2 1 "20 Microns Ltd." 20689 679 2016 38.9 1 "20 Microns Ltd." 20690 679 2016 39.35 1 "20 Microns Ltd." 20691 679 2016 38.6 1 "20 Microns Ltd." 20692 679 2016 38.7 1 "20 Microns Ltd." 20695 679 2016 37.7 1 "20 Microns Ltd." 20696 679 2016 38.05 1 "20 Microns Ltd." 20697 679 2016 38.2 1 "20 Microns Ltd." 20698 680 2016 36.3 1 "20 Microns Ltd." 20699 680 2016 37.45 1 "20 Microns Ltd." 20703 680 2016 36.95 1 "20 Microns Ltd." 20704 680 2016 37.45 1 "20 Microns Ltd." 20705 680 2016 37.55 1 "20 Microns Ltd." 20706 680 2016 37.55 1 "20 Microns Ltd." 20709 680 2016 36.65 1 "20 Microns Ltd." 20711 680 2016 36.7 1 "20 Microns Ltd." 20712 680 2016 36.65 1 "20 Microns Ltd." 20713 680 2016 37.45 1 "20 Microns Ltd." 20716 680 2016 36.85 1 "20 Microns Ltd." 20717 680 2016 37 1 "20 Microns Ltd." 20718 680 2016 36.75 1 "20 Microns Ltd." 20719 680 2016 38.95 1 "20 Microns Ltd." 20720 680 2016 38.3 1 "20 Microns Ltd." 20723 680 2016 38.15 1 "20 Microns Ltd." 20724 680 2016 38.3 1 "20 Microns Ltd." 20725 680 2016 38.25 1 "20 Microns Ltd." 20726 680 2016 35.15 1 "20 Microns Ltd." 20727 680 2016 36.45 1 "20 Microns Ltd." 20730 681 2016 36.7 1 "20 Microns Ltd." 20731 681 2016 36.2 1 "20 Microns Ltd." 20732 681 2016 36.4 1 "20 Microns Ltd." 20733 681 2016 36.5 1 "20 Microns Ltd." 20734 681 2016 36.4 1 "20 Microns Ltd." 20737 681 2016 35.7 1 "20 Microns Ltd." 20740 681 2016 35.2 1 "20 Microns Ltd." 20741 681 2016 37.8 1 "20 Microns Ltd." 20744 681 2016 38.05 1 "20 Microns Ltd." 20745 681 2016 38.55 1 "20 Microns Ltd." 20746 681 2016 39 1 "20 Microns Ltd." 20747 681 2016 39 1 "20 Microns Ltd." 20748 681 2016 39.45 1 "20 Microns Ltd." 20751 681 2016 39.9 1 "20 Microns Ltd." 20752 681 2016 39.6 1 "20 Microns Ltd." 20753 681 2016 39.65 1 "20 Microns Ltd." 20754 681 2016 38.5 1 "20 Microns Ltd." 20755 681 2016 39.95 1 "20 Microns Ltd." 20757 681 2016 40.65 1 "20 Microns Ltd." 20759 682 2016 41.75 1 "20 Microns Ltd." 20760 682 2016 40 1 "20 Microns Ltd." 20761 682 2016 42.55 1 "20 Microns Ltd." 20762 682 2016 41 1 "20 Microns Ltd." 20765 682 2016 43.15 1 "20 Microns Ltd." 20766 682 2016 42.15 1 "20 Microns Ltd." 20767 682 2016 40.8 1 "20 Microns Ltd." 20768 682 2016 40.9 1 "20 Microns Ltd." 20769 682 2016 39.05 1 "20 Microns Ltd." 20773 682 2016 36.15 1 "20 Microns Ltd." 20774 682 2016 36.15 1 "20 Microns Ltd." 20775 682 2016 34 1 "20 Microns Ltd." 20776 682 2016 34.55 1 "20 Microns Ltd." 20779 682 2016 32.35 1 "20 Microns Ltd." 20780 682 2016 32.6 1 "20 Microns Ltd." 20781 682 2016 34.35 1 "20 Microns Ltd." 20782 682 2016 34.7 1 "20 Microns Ltd." 20783 682 2016 35.45 1 "20 Microns Ltd." 20786 682 2016 35.75 end format %td date format %tm mdate

Comment