DATA Step, Macro, Functions and more

retain the non missing previous value and compare the values between the variables

Reply
Contributor
Posts: 25

retain the non missing previous value and compare the values between the variables

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

SubIDDate1Visit1Visit2Date2
A10034-Sep-17week 45  
A1003  Unscheduled4-Sep-17
A1005  Week 653-Apr-17
A1006  Early Discontinuation20-Oct-17
A100928-Aug-17Discont  
A1009  Visit 20 or Early Withdrawal28-Aug-17
A1009  Unscheduled28-Aug-17
A1011  Discont25-Oct-17
A1011  Week 788-Jun-17
A101721-Aug-17Discont  
A1017  Unscheduled21-Aug-17
A1017  Week 6511-Oct-17
A1020  Week 455-Apr-17
A10206-Apr-17Week 45  
A102112-Oct-17Unscheduled  
A1021  Week 2412-Oct-17
A10215-Oct-17Week 24  
A1025  Week 720-Oct-17
A1029  Unscheduled29-Apr-16
A1029  Unscheduled7-Dec-15
A102929-Apr-16Week 13  

 

output dataset

SubIDDate1Visit1Visit2Date2date_missmatchVisit_missmatchabsent in date1absent in date2
A10034-Sep-17week 45Unscheduled4-Sep-17 yes  
A1005  Week 653-Apr-17  yes 
A1006  Early Discontinuation20-Oct-17  yes 
A100928-Aug-17DiscontWeek 1028-Aug-17 yes  
A100928-Aug-17DiscontUnscheduled28-Aug-17 yes  
A1011  Discont25-Oct-17  yes 
A1011  Week 788-Jun-17  yes 
A101721-Aug-17DiscontUnscheduled21-Aug-17 yes  
A1017  Week 6511-Oct-17  yes 
A10206-Apr-17Week 45Week 455-Apr-17yes   
A102112-Oct-17UnscheduledWeek 2412-Oct-17 yes  
A10215-Oct-17Week 24Week 2412-Oct-17yes   
A1025Week 720-Oct-17     yes
A102929-Apr-16Week 13Unscheduled29-Apr-16 yes  
A1029  Unscheduled7-Dec-15  yes 
Super Contributor
Posts: 498

Re: retain the non missing previous value and compare the values between the variables

Posted in reply to SrikanthY
What is the question?
Contributor
Posts: 25

Re: retain the non missing previous value and compare the values between the variables

Posted in reply to andreas_lds
Please check the required output. from the provided input data.

want to flag inconstant dates and visits.
Respected Advisor
Posts: 4,543

Re: retain the non missing previous value and compare the values between the variables

Posted in reply to SrikanthY

@SrikanthY

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.

Ask a Question
Discussion stats
  • 3 replies
  • 134 views
  • 0 likes
  • 3 in conversation