Since we will test the first sample anyway the beginning is easy: gen Test1=Spec1 Test4 should be as close as possible to (Startdate + 608 days) and must be > (StartDate + 61 days) and must be < (EndDate - 91 days) Test2 should be as close as possible to (StartDate+243 days) and must be > (StartDate + 61 days) and must be < (Test4 - 61 days) Test3 should be as close as possible to the midpoint between Test3 and Test4 and must be > (Test2 + 61 days) and must be < (Test4 - 61days) Thanks in advance for your help, Elmar * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/