retain the date1 value for the same subject and compare with date2. and for vistis also..
condition1 if dates are matching and visits are not matching then visit missmatch.
condition2 if visits are matching and dates are not matching then date missmatch.
condition3 if single subject then flag as present in date1 or date2 vice versa.
condition 4: for multiple rows (ex:A1017, A1029) should compare only if dates or visits are matching other wise apply condition3.
Input dataset
SubID | Date1 | Visit1 | Visit2 | Date2 |
A1003 | 4-Sep-17 | week 45 | ||
A1003 | Unscheduled | 4-Sep-17 | ||
A1005 | Week 65 | 3-Apr-17 | ||
A1006 | Early Discontinuation | 20-Oct-17 | ||
A1009 | 28-Aug-17 | Discont | ||
A1009 | Visit 20 or Early Withdrawal | 28-Aug-17 | ||
A1009 | Unscheduled | 28-Aug-17 | ||
A1011 | Discont | 25-Oct-17 | ||
A1011 | Week 78 | 8-Jun-17 | ||
A1017 | 21-Aug-17 | Discont | ||
A1017 | Unscheduled | 21-Aug-17 | ||
A1017 | Week 65 | 11-Oct-17 | ||
A1020 | Week 45 | 5-Apr-17 | ||
A1020 | 6-Apr-17 | Week 45 | ||
A1021 | 12-Oct-17 | Unscheduled | ||
A1021 | Week 24 | 12-Oct-17 | ||
A1021 | 5-Oct-17 | Week 24 | ||
A1025 | Week 7 | 20-Oct-17 | ||
A1029 | Unscheduled | 29-Apr-16 | ||
A1029 | Unscheduled | 7-Dec-15 | ||
A1029 | 29-Apr-16 | Week 13 |
output dataset
SubID | Date1 | Visit1 | Visit2 | Date2 | date_missmatch | Visit_missmatch | absent in date1 | absent in date2 |
A1003 | 4-Sep-17 | week 45 | Unscheduled | 4-Sep-17 | yes | |||
A1005 | Week 65 | 3-Apr-17 | yes | |||||
A1006 | Early Discontinuation | 20-Oct-17 | yes | |||||
A1009 | 28-Aug-17 | Discont | Week 10 | 28-Aug-17 | yes | |||
A1009 | 28-Aug-17 | Discont | Unscheduled | 28-Aug-17 | yes | |||
A1011 | Discont | 25-Oct-17 | yes | |||||
A1011 | Week 78 | 8-Jun-17 | yes | |||||
A1017 | 21-Aug-17 | Discont | Unscheduled | 21-Aug-17 | yes | |||
A1017 | Week 65 | 11-Oct-17 | yes | |||||
A1020 | 6-Apr-17 | Week 45 | Week 45 | 5-Apr-17 | yes | |||
A1021 | 12-Oct-17 | Unscheduled | Week 24 | 12-Oct-17 | yes | |||
A1021 | 5-Oct-17 | Week 24 | Week 24 | 12-Oct-17 | yes | |||
A1025 | Week 7 | 20-Oct-17 | yes | |||||
A1029 | 29-Apr-16 | Week 13 | Unscheduled | 29-Apr-16 | yes | |||
A1029 | Unscheduled | 7-Dec-15 | yes |
1. Post your input data via a valid SAS data step creating a SAS table
2. Please don't expect people to do all the work for you. What have you done so far? Eventually post your not yet fully working code and some explanation of your approach.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.