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

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 473 views
  • 2 likes
  • 2 in conversation