Hello,

Below is part of my dataset.

What i wanna do is that for same individual with outcome=1 only keep the observations with outcome=1, meanwhile don't delete other individuals.

So, in this example, I want to keep the first 4 rows.

Could anyone help with this issue?

Thank you!!

Best,
Z

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long lopnr str7 dia float outcome
 9717 "I862" 0
 9717 "R103" 0
10006 "I470" 1
10006 "I471" 1
10006 "I839" 0
10006 "I951" 0
end