BookmarkSubscribeRSS Feed
mauri0623
Quartz | Level 8

Starting with the dataset below, we need to identify the index encounter, which is the encounter_date closest to the start_date.
Encounter_date may be up to two weeks prior to intake survey date(start_Date) through 1 week after it
We also need to apply a washout period. To qualify as an index encounter, there must be no other encounters within 183 days prior to the 2 week grace period, up to two weeks before the index period.

Person_ID Encoured_Date Start_Date
00006A7087 10/7/2021 4/5/2022
00006A7087 11/5/2021 4/5/2022
00006A7087 11/15/2021 4/5/2022
00006A7087 12/2/2021 4/5/2022
00006A7087 12/14/2021 4/5/2022
00006A7087 12/21/2021 4/5/2022
00006A7087 1/3/2022 4/5/2022
00006A7087 1/18/2022 4/5/2022
00006A7087 1/25/2022 4/5/2022
00006A7087 2/4/2022 4/5/2022
00006A7087 2/8/2022 4/5/2022
00006A7087 2/17/2022 4/5/2022
00006A7087 3/2/2022 4/5/2022
00006A7087 3/8/2022 4/5/2022
00006A7087 3/18/2022 4/5/2022
00006A7087 4/5/2022 4/5/2022
00006A7087 4/12/2022 4/5/2022
0000E20E92 1/28/2022 4/5/2022
0000E20E92 3/22/2022 4/5/2022
0000E20E92 4/5/2022 4/5/2022
0000E20E92 5/3/2022 4/5/2022
0000E20E92 5/17/2022 4/5/2022
0000E20E92 5/31/2022 4/5/2022
0000E20E92 7/15/2022 4/5/2022
0000E20E92 8/9/2022 4/5/2022
0000E20E92 10/19/2022 4/5/2022
0000E20E92 11/30/2022 4/5/2022
I know how to go 1 week forward and two weeks backward using the intnx function. I however don'w know about how to construct the washout period part.

4 REPLIES 4
ballardw
Super User

@mauri0623 wrote:

Starting with the dataset below, we need to identify the index encounter, which is the encounter_date closest to the start_date.
Encounter_date may be up to two weeks prior to intake survey date(start_Date) through 1 week after it
We also need to apply a washout period. To qualify as an index encounter, there must be no other encounters within 183 days prior to the 2 week grace period, up to two weeks before the index period.

<data removed>
I know how to go 1 week forward and two weeks backward using the intnx function. I however don'w know about how to construct the washout period part.


I do not see any clear rules defining what the "washout period" is. Or what "apply" means.

 

mauri0623
Quartz | Level 8
Washout is 183 days from the grace period of the one week forward and two weeks backward.
ballardw
Super User

You are using terms that are likely intimately familiar to you. However, I do not know exactly what your definition of grace period is or when it starts.

Is 183 days actually days or a supposed to be "6 months" or similar?

 


@mauri0623 wrote:
Washout is 183 days from the grace period of the one week forward and two weeks backward.

One week forward from which specific date (or exactly how to derive that date given your example data set), similar "two weeks backward" from which date? And weeks may need some clarification. The day at the start of the week? Do you use Sunday, Monday or a different day of the week as start? Or is "week" exactly 7 days? Or the Sunday of the week that is 7 days prior (or after?). Or the first working day of week?

 

Date intervals need very explicit rules and unfortunately there are multiple definitions of some of these. Look at the WEEK function documentation for example. It has 3 values for a parameter that are involved in defining the starting day of a "week" at the beginning of a year. 

 

You should show an example of the desired output so that we can see how you use your rules and to show the result after the "apply" as in "We also need to apply a washout period." Does apply mean set a flag? Remove observations? Add some value to an existing variable? Create additional observations?

mkeintz
PROC Star

"identify the index encounter, which is the encounter_date closest to the start_date"

 

Questions:

  1. What if there is a tie?  If one date precedes start_date by the same number of days as another follows start_date, which one is selected as the index date.
  2. As per @ballardw 's note, what to you mean by "one week" and "two weeks"?  Do you mean exactly 7 or 14 days?  Or do you ignore weekends or other days?
  3. Does each person_id has only a single start_date value, as in your sample date?   If so, do all your person_id's have the same start_date, as in your sample data?
  4. What do you want the output data to look like?  Or if it is a report, what do you want it to look like?
  5. If there is an encounter in the washout period, in what way will the output be different?
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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 25. 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
  • 4 replies
  • 647 views
  • 0 likes
  • 3 in conversation