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
How to recode a trinary variable into a binaryHello. I'm new to Stata, and I have a quick question. I have a variable "size" in my data base : 1 i…
Two-part modeling: combination of LCA and LPAHi Statalists, I was trying to do a two-part modeling for my dataset, in which observed vars are ze…
PCA with weights?Dear All, I was wondering if weights should be used with the PCA command when constructing an index …
Using bayesstats summary on pooled multiple chain data.Dear Statalisters, Is there a way to summarize amalgamated data from multiple chains with bayesstats…
Counting observations over duplicate datesHi all, I'm an economics student in college, doing my best to learn STATA. I've browsed the forum a…
Subscribe to:
Post Comments (Atom)
0 Response to Deleting observations from a panel data according to a criteria
Post a Comment