Hi,
I am quite new to STATA (shame on me) and am trying to figure out how to get a desired dataset from a big longitudinal dataset. I have a balanced dataset with individuals (id) over 9 years (2006-2014). But I am not interested in all of them. I only want to have a dataset of individuals who lived in two groups of districts in the first 5 years (2006-2010). So let's say one set contains Treatment={a, b, c, d} and the other set contains Control={e, f, g, h}.
So for each id in the dataset, check if
-for all t from 2006 to 2010 if id(district) is in Treatment then keep
OR
-for all t from 2006 to 2010 if id(district) is in Control then keep
IF NEITHER HOLDS
then delete the id and all observations for all variables for all the years in the dataset (i.e. 2006-2004).
I know in my head what I want STATA to do, but I cannot write the code for it.. I am sorry if it is a too primitive question. I hope I'll improve over time and come with better questions.
Best,
Merve
Related Posts with Deleting observations from a panel data according to a criteria
Unrecognized command (spbalance)Dear Stata senior users, I am preparing my spatial panel data without shapefile (as instructed at ht…
New to Stata. Haven't seen this before. Please help.When I launch Stata15 and run the following: clear all drop _all gen f2 = 3 gen p2 = normal(f2) dis…
Set a specific folder to save regression outputs and graphsHello! I need to set a specific folder (directory), different from the current working directory, t…
System GMM omitted variablesDear Sirs, I have received the following comment from a reviewer: "what are the main omitted variab…
Missing data are not missing - how to make a date field blank?Hi. I am a new user and have a somewhat strange question: I have a dataset with observations (rows)…
Subscribe to:
Post Comments (Atom)
0 Response to Deleting observations from a panel data according to a criteria
Post a Comment