Hello,
I have posted my data below. Some individuals have 2 records. I would like to keep those records where an individual has a single record only or where Index==2 (i.e., the 2nd record). I manually created the variable keep to show the records I wish to retain. I would be grateful for advice on how to write code for the variable keep. Thank you!
I have posted my data below. Some individuals have 2 records. I would like to keep those records where an individual has a single record only or where Index==2 (i.e., the 2nd record). I manually created the variable keep to show the records I wish to retain. I would be grateful for advice on how to write code for the variable keep. Thank you!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ID Index keep) 1 1 1 2 1 . 2 2 1 3 1 . 3 2 1 4 1 1 5 1 1 end
Comment