I have discovered that I have duplicates for a whole row (same person).. how do I delete the rows without getting missing values?
-
Login or Register
- Log in with
. sysuse auto, clear (1978 Automobile Data) . expand 2 in 42 (1 observation created) . duplicates list Duplicates in terms of all variables +--------------------------------------------------------------------------------------+ | obs: | make | price | mpg | rep78 | headroom | trunk | weight | length | turn | | 42 | Plym. Arrow | 4,647 | 28 | 3 | 2.0 | 11 | 3,260 | 170 | 37 | |----------------------------+---------------------------------------------------------| | displa~t | gear_r~o | foreign | | 156 | 3.05 | Domestic | +--------------------------------------------------------------------------------------+ +--------------------------------------------------------------------------------------+ | obs: | make | price | mpg | rep78 | headroom | trunk | weight | length | turn | | 75 | Plym. Arrow | 4,647 | 28 | 3 | 2.0 | 11 | 3,260 | 170 | 37 | |----------------------------+---------------------------------------------------------| | displa~t | gear_r~o | foreign | | 156 | 3.05 | Domestic | +--------------------------------------------------------------------------------------+ . duplicates drop Duplicates in terms of all variables (1 observation deleted) . duplicates list Duplicates in terms of all variables (0 observations are duplicates)
. clear . set obs 5 number of observations (_N) was 0, now 5 . set seed 1234 . gen obsno=_n . forvalues x=1/3{ 2. gen x`x' = runiformint(1,3) 3. } . list,noobs +----------------------+ | obsno x1 x2 x3 | |----------------------| | 1 1 1 1 | | 2 1 1 2 | | 3 1 1 1 | | 4 1 1 3 | | 5 2 3 3 | +----------------------+ . egen diff = diff(*) . drop if !diff (1 observation deleted) . list,noobs +-----------------------------+ | obsno x1 x2 x3 diff | |-----------------------------| | 2 1 1 2 1 | | 3 1 1 1 1 | | 4 1 1 3 1 | | 5 2 3 3 1 | +-----------------------------+
Comment