I would like to remove all observations of a company if there is one trading day without data.
My data set currently contains the first 3 columns of the following subset and my idea was to create a 4th column "suffdata" that would get a 1 if the company has one empty return in the sample.
My Code looks the following, but I do not know what to put behind the if statement, does somebody know what to put there?
* Remove companies with missing observations
gen suffdata = 0
replace suffdata = 1 if
drop if suffdata == 1
Date | Company | Return | suffdata (Column not created) |
1 | x | . | 1 |
1 | x | . | 1 |
1 | x | 2 | 1 |
2 | y | 1 | 0 |
2 | y | 1 | 0 |
2 | y | 3 | 0 |
3 | z | 2 | 1 |
3 | z | 1 | 1 |
3 | z | . | 1 |
0 Response to Data cleaning - drop all observations for ID if one observation in var x contains xyz
Post a Comment