Hello everyone,

I'd like to know if there's a way to keep in my dataset, the observations that are returned from a list. To give you some context, I have a panel data set, where I want to keep just some IDs that satisfy certain condition on the initial year. So I get the list of the IDs that I need, but it's too large to write a keep if, so I would like to keep the observations that only have those IDs.

Below it's the code that returns the IDs (which are called mrun in this database) that I need to keep.

Code:
list mrun if cod_ense2==2 & agno==2016 & (cod_grado==1 | cod_grado==2 | cod_grado==3 | cod_grado==4)
Thanks for the help!