Hi,
Each patient was asked twice to recall their date of first treatment. The dates might be inconsistent because there is recall bias. I would like to create a new variable indicating there is a huge difference between the two dates. The definition of "huge difference" could be 1 year.
Patient ID Recall date1 Recall date2 Huge Difference (This is what I want)
001 08/05/2006 09/2006 NO
002 05/24/2006 05/2007 YES
003 02/08/2007 08/2006 NO
004 08/12/2010 11/2007 YES
Given the formats were different, how do I do the calculation and create the variable I need? Thanks in advance!
Are Recall_date_1 and Recall_date_2 text strings, or are they actual SAS date values? In other words, does PROC CONTENTS show these variables as numeric, or character?
Both are numeric. Recall 1 has MMDDYY10. format. Recall has MMYYS7. format.
So both are SAS date values, and all you need to do to determine the difference is subtract them. The formatting does not change the underlying SAS date value.
data want;
set have;
length huge $ 3;
if abs(recall1-recall2)>365 then huge='YES';
else huge='NO';
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.