Hello, I am trying to create an "index visit" where an individual has 90 days of eligibly period before the index visit and 365 days after the index visit.

Eligibily date is "pert_Eligible_Period_Dt and the index visit date is "pert_service_start_dt

All of my cases have at least 15 months of continuous eligibility.


I realize this is a simple coding problem but I have not been successful in working through this! If you can point me in the right direction that would be great.

* Example generated by -dataex-. To install: ssc install dataex
clear
input long unique_member_id str10 pert_Eligible_Period_Dt float(eligibility_date2 pert_service_start_dt_rc)
15 "2013-01-01" 39373 39699
15 "2013-02-01" 39404 39699
15 "2013-03-01" 39432 39699
15 "2013-04-01" 39463 39699
15 "2013-05-01" 39493 39699
15 "2013-06-01" 39524 39699
15 "2013-07-01" 39554 39699
15 "2013-08-01" 39585 39699
15 "2013-09-01" 39616 39699
15 "2013-10-01" 39646 39699
15 "2013-11-01" 39677 39699
15 "2013-12-01" 39707 39699
15 "2014-01-01" 39738 39699
15 "2014-02-01" 39769 39699
15 "2014-03-01" 39797 39699
15 "2014-04-01" 39828 39699
15 "2014-05-01" 39858 39699
15 "2014-06-01" 39889 39699
15 "2014-07-01" 39919 39699
15 "2014-08-01" 39950 39699
15 "2014-09-01" 39981 39699
15 "2014-10-01" 40011 39699
15 "2014-11-01" 40042 39699
20 "2015-02-27" 40160 40446
20 "2015-03-30" 40191 40446
20 "2015-04-29" 40221 40446
20 "2015-05-30" 40252 40446
20 "2015-06-29" 40282 40446
20 "2015-07-30" 40313 40446
20 "2015-08-30" 40344 40446
20 "2015-09-29" 40374 40446
20 "2015-10-30" 40405 40446
20 "2015-11-29" 40435 40446
20 "2015-12-30" 40466 40446
20 "2016-01-30" 40497 40446
20 "2016-02-28" 40526 40446
20 "2016-03-30" 40557 40446
20 "2016-04-29" 40587 40446
21 "2012-12-30" 39371 39877
21 "2013-01-30" 39402 39877
21 "2013-02-27" 39430 39877
21 "2013-03-30" 39461 39877
21 "2013-04-29" 39491 39877
21 "2013-05-30" 39522 39877
21 "2013-06-29" 39552 39877
21 "2013-07-30" 39583 39877
21 "2013-08-30" 39614 39877
21 "2013-09-29" 39644 39877
21 "2013-10-30" 39675 39877
21 "2013-11-29" 39705 39877
21 "2013-12-30" 39736 39877
21 "2014-01-30" 39767 39877
21 "2014-02-27" 39795 39877
21 "2014-03-30" 39826 39877
21 "2014-04-29" 39856 39877
21 "2014-05-30" 39887 39877
21 "2014-06-29" 39917 39877
21 "2014-07-30" 39948 39877
21 "2014-08-30" 39979 39877
21 "2014-09-29" 40009 39877
21 "2014-10-30" 40040 39877
21 "2014-11-29" 40070 39877
21 "2014-12-30" 40101 39877
21 "2015-01-30" 40132 39877
21 "2015-02-27" 40160 39877
21 "2015-03-30" 40191 39877
21 "2015-04-29" 40221 39877
21 "2015-05-30" 40252 39877
21 "2015-06-29" 40282 39877
21 "2015-07-30" 40313 39877
21 "2015-08-30" 40344 39877
21 "2015-09-29" 40374 39877
21 "2015-10-30" 40405 39877
21 "2015-11-29" 40435 39877
21 "2015-12-30" 40466 39877
23 "2012-12-29" 39370 39837
23 "2013-01-29" 39401 39837
23 "2013-02-26" 39429 39837
23 "2013-03-29" 39460 39837
23 "2013-04-28" 39490 39837
23 "2013-05-29" 39521 39837
23 "2013-06-28" 39551 39837
23 "2013-07-29" 39582 39837
23 "2013-08-29" 39613 39837
23 "2013-09-28" 39643 39837
23 "2013-10-29" 39674 39837
23 "2013-11-28" 39704 39837
23 "2013-12-29" 39735 39837
23 "2014-01-29" 39766 39837
23 "2014-02-26" 39794 39837
23 "2014-03-29" 39825 39837
23 "2014-04-28" 39855 39837
23 "2014-05-29" 39886 39837
23 "2014-06-28" 39916 39837
23 "2014-07-29" 39947 39837
23 "2014-08-29" 39978 39837
23 "2014-09-28" 40008 39837
23 "2014-10-29" 40039 39837
23 "2014-11-28" 40069 39837
23 "2014-12-29" 40100 39837
end
format %td eligibility_date2
format %td pert_service_start_dt_rc
[/CODE]