BookmarkSubscribeRSS Feed
Denali
Quartz | Level 8

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! 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
Denali
Quartz | Level 8

Both are numeric. Recall 1 has MMDDYY10. format. Recall has MMYYS7. format.

PaigeMiller
Diamond | Level 26

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;

 

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

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
  • 3 replies
  • 816 views
  • 2 likes
  • 2 in conversation