I am working with a longitudinal data set. I am interested in keeping individuals in the data if they have MBI_total score>0 at two time points within 1.5 years. This has to be the first two visits that meet this criteria.
This is the code I have so far:
Code:
sort naccid naccvnum bysort naccid (naccvnum): gen Followup= (dateofvisit - dateofvisit[_n-1])/365 replace Followup=0 if Followup==.
Code:
* Example generated by -dataex-. To install: ssc install dataex dataex naccid naccvnum MBI_total dateofvisit Followup clear input str10 naccid byte naccvnum float(MBI_total dateofvisit Followup) "NACC000011" 1 2 16908 0 "NACC000011" 2 1 17335 1.169863 "NACC000034" 1 1 20285 0 "NACC000034" 3 1 21080 2.1780822 "NACC000162" 1 1 17966 0 "NACC000162" 9 3 21133 8.676712 "NACC000162" 10 10 21567 1.1890411 "NACC000271" 3 1 18031 0 "NACC000271" 4 6 18469 1.2 "NACC000271" 5 4 18868 1.0931507 "NACC000271" 6 3 19276 1.1178082 "NACC000382" 1 4 16706 0 "NACC000382" 2 4 17071 1 "NACC000382" 3 5 17434 .9945205 "NACC000382" 4 4 17826 1.0739726 "NACC000382" 5 2 18351 1.438356 "NACC000385" 1 1 17113 0 "NACC000385" 4 3 18373 3.452055 "NACC000385" 5 1 18655 .7726027 "NACC000385" 6 2 18996 .9342466 end format %td dateofvisit
Code:
drop if Followup>=1.5
Thank you
0 Response to Dropping rows that do not meet the follow up time cut off
Post a Comment