QRP
 
Loading...
Searching...
No Matches
ms_periodsoverlap.sas File Reference

This macro creates combinations of variables for WHERE or IF condition.
More...

Detailed Description

This macro creates combinations of variables for WHERE or IF condition.

There must be at least one day of overlap between the periods. From Joe Celko, SQL for Smarties, 3rd Edition, Chapter 13, page 280.
Celko says that where arrival_date between start_date and finish_date
or depart_date between start_date and finish_date
or start_date between arrival_date and depart_date
or finish_date between arrival_date and depart_date
is equivalent to
where not ((depart_date < start_date) or (arrival_date > finish_date))
simplifying a bit more, we get
((&DEPART_DATE. >= &START_DATE.) and (&ARRIVAL_DATE. <= &FINISH_DATE.))

Program inputs
None.
Program outputs
None.

Usage

%periods_overlap(period1=rxdate @ calculated rxend,                             
                 period2=elig.DRS_Baseline_Start_Dt @ elig.DRS_Baseline_End_Dt, 
                 delim=@); 
Parameters
[in]PERIOD1Represents the first time period. It is expected to be a string containing two values separated by a delimiter. The first value is the start of the period, and the second value is the end of the period. If only one value is provided, it is assumed to be both the start and end of the period.
[in]PERIOD2Represents the second time period. It is a string containing two values separated by a delimiter. The first value is the start of the period, and the second value is the end of the period. If only one value is provided, it is assumed to be both the start and end of the period.
[in]DELIMUsed when one of the dates is an expression containing a space. The space character is used as a delimiter by default if an expression needs contain a space, specify a different character in DELIM= and then use that character to separate the start and end dates in the PERIOD parameters. Don't use a comma as the delimiter.

SAS Macros Dependencies

None.

Author
Sentinel Coordinating Center (info@.nosp@m.sent.nosp@m.inels.nosp@m.yste.nosp@m.m.org)