Estimating treatment effects in observational studies with both prevalent and incident cohorts