Conditional Lag and retention
Good day
I kindly need help to generate a conditional lag in TSQL.
If the visit is a D01 visit and VIS_DAT data is present- retain VIS_DAT
If the visit is a D01/D08 visit the VIS_DAT data is missing- lag the last VIS_DAT from D01 and retain it until next visit
Example attached