data employee_work_duration;
INFILE CARDS MISSOVER ;
input empid department $ work_start:date9. work_end:date9. ;
format work_start work_end date9. ;
cards;
101 A 01JAN2023 03JAN2023
101 A 03JAN2023
101 A 03JAN2023
101 A 04JAN2023 06JAN2023
101 A 05JAN2023
101 A 06JAN2023
101 A 07JAN2023 14JAN2023
101 A 10JAN2023
101 B 01FEB2023 03FEB2023
101 B 03FEB2023
101 B 03FEB2023
101 B 04FEB2023 06FEB2023
101 B 05FEB2023
101 B 06FEB2023
101 B 07FEB2023 14FEB2023
101 B 10FEB2023 18FEB2023
RUN;
/*QUERY*/
Assign flags for wrong entry records
For example:
1) Don't start next record without ending previous record with in same department (for example: see record number 2,3)
2) Don't get repeated date/with in the range date record . For example see record number 15 and 16 . Here 16th record date is '10FEB2023' this date is equal to with in range of 15th record '07FEB2023'/'14FEB2023'
/**Final Output**/
empid department work_start work_end WRONG_ENTRY
101 A 01JAN2023 03JAN2023
101 A 03JAN2023 Y
101 A 03JAN2023 Y
101 A 04JAN2023 06JAN2023
101 A 05JAN2023 Y
101 A 06JAN2023 Y
101 A 07JAN2023 14JAN2023
101 A 10JAN2023
101 B 01FEB2023 03FEB2023
101 B 03FEB2023 Y
101 B 03FEB2023 Y
101 B 04FEB2023 06FEB2023
101 B 05FEB2023 Y
101 B 06FEB2023 Y
101 B 07FEB2023 14FEB2023
101 B 10FEB2023 18FEB2023 Y
Please help me out