I have UK panel data from the British Household Panel Survey and Understanding data, covering 2000-2016 in a variable "year" with individual identifiers "pidp".
How do I keep those variables that appear at least once before 2007 and at least once after 2007 - I am looking the impact of a UK policy that came into effect and hence am trying to limit the sample to those individuals that appear both before and after the threshold?
I have tried a combination of the following, limiting to those who only answered for than say 9 years to ensure they are before and after but this greatly limits the data:
bysort pidp : drop if _N < 2 //*13,495
bysort pidp : drop if _N < 3 //*16, 530
bysort pidp : drop if _N < 4 //*17,190
bysort pidp : drop if _N < 5 //*15,936
bysort pidp : drop if _N < 6 //*18,120
bysort pidp : drop if _N < 7 //*21,522
bysort pidp : drop if _N < 8 //*28,924
bysort pidp : drop if _N < 9 //*32,080
Thanks,
Joshua
Related Posts with Panel Data - Keeping Observations when using a Difference in Difference Approach
Adding Log-rank test p-value to the Kaplan Meier graphHello everyone, I am trying to add Log-rank test p-value to my Kaplan Meier graph, but I cannot fin…
Counting concurrent use of three or more types of medication within an administrative claims databaseDear Statalist, I am working to count a range of medication-related problems using an administrativ…
RD Graph issueHi all, My Code: scatter aux1hm aux1dm, leg(off) || line lochd0m locd0m, leg(off) lpattern(solid d…
Table with quartilesI want to create a table showing basic characteristics with the quartiles of a dependent variable, I…
Carryforward Code: * Example generated by -dataex-. To install: ssc install dataex clear input float…
Subscribe to:
Post Comments (Atom)
0 Response to Panel Data - Keeping Observations when using a Difference in Difference Approach
Post a Comment