0
votes

I have a large dataset but I do not need all observations. The dataset contains data for every day within the period from 1989 to 2019. How can I delete all observations in Stata except for the last day of each year and per each firm?

So 12/31/1989, 12/31/1990,12/31/1991....12/31/2019 should be kept. (the variable name and format is attached with the image)

Thank you very much! Best regards Sven

Overview about dataset format/variables

1

1 Answers

2
votes
gen year = year(DATE)
bysort PERMNO year (DATE) : keep if _n == _N