Hi all,
Apologies, but I have an admittedly rudimentary question on how to filter my data set. As a minimal working example, say I have the following,
I'd like to keep IDs that exhibit a certain value on another variable at any point in time. Using the above minimal example, I'd like to keep all ID's that scored a 5 on my variable and yield the following,
I attempted to use keep id if variable == 5 but invalid. I suspect I'm missing something rather obvious and appreciate suggestions. Thank you in advance!
Apologies, but I have an admittedly rudimentary question on how to filter my data set. As a minimal working example, say I have the following,
Code:
ssc install dataex clear input byte id int year int variable 1 1980 1 1 1981 5 1 1982 2 2 1980 0 2 1981 2 2 1982 4 3 1980 1 3 1981 0 3 1982 0 4 1980 5 4 1981 1 4 1982 4 end list
Code:
+----------------------+ | id year variable | |----------------------| 1. | 1 1980 1 | 2. | 1 1981 5 | 3. | 1 1982 2 | 4. | 4 1980 5 | 5. | 4 1981 1 | |----------------------| 6. | 4 1982 4 | +----------------------+
Comment