Not applicable
Posts: 1

# how to get the time interval in 90 days apart

I have a patient data set with all the dates that the patients attend the services. i want to calculate the retention date which is defined as: at least 2 visit dates 90 days apart. I transpose the data and calculated it but wondering is anybody have a better and easy way to do this?

example of the data set:

data test;

input id visit_dt;

cards;

1 01/12/2010

1 03/10/2010

1 06/13/2010

1 12/13/2010

2 01/12/2010

2 01/13/2010

2 03/13/2010

2 06/14/2010

;

run;

Super User
Posts: 23,776

## Re: how to get the time interval in 90 days apart

Posted in reply to juliajulia

What do you want the output to be?

Super Contributor
Posts: 644

## Re: how to get the time interval in 90 days apart

Posted in reply to juliajulia

Transposing the data allows all the incidents per ID to be in the same row, so they are all available in memory.  The un-transposed data as shown could be analysed with multiple lag functions but you would need to know the maximum number of events per ID for the period to set up the required number of lags.  You say you have a solution for the transposed data so I would stick with that (kinda curious to see how you proceeded, though).

Richard

Super User
Posts: 13,583

## Re: how to get the time interval in 90 days apart

Posted in reply to juliajulia

I think we need to know more about how you define retained. "At least 2 visits 90 days apart" is subject to several interpretations. For example is the 90 days exactly equal (unlikely but...) less than equal to 90 days, strictly less than 90 days, greater than or equal to 90 days or strictly greater than 90 days.

Are the visits compared sequentially or over multiple visits (this is a big distinction if the intervals are greater than 90).

If sequential and less than 90 days then how do report something where the first 3 visit are considered retained but the last 2 or 3 visits are outside?

You data example should include which are considered retained and show at least one set that is retained and one which is not.

I've had to go over similar issues with my clients to get them to really define what they are looking for.

Discussion stats
• 3 replies
• 291 views
• 0 likes
• 4 in conversation