BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5
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
1 REPLY 1
tomvincent
Fluorite | Level 6
What have you tried so far?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 507 views
  • 0 likes
  • 2 in conversation