<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to identify overlap and calculate overlap time period in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681675#M206211</link>
    <description>&lt;P&gt;This is NOT a data size issue.&amp;nbsp; It is a date-range issue.&amp;nbsp; That's why the message says "array subscript out of range".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The out-of-range means that you have dates before 01jan2016&amp;nbsp; or after 31dec2018, which the defined array can't accommodate.&amp;nbsp; That's why I said " Let's say all your prescription supplies are meant to be completely used between 01jan2016 through 31dec2018."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So just change the two %LET statements to accomodate then entire possible history of your data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2020 16:01:05 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-09-04T16:01:05Z</dc:date>
    <item>
      <title>How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680831#M205854</link>
      <description>&lt;P&gt;Hi SAS Pros,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a project that needs to define whether there are any &lt;U&gt;&lt;STRONG&gt;overlap of taking drug A and B happened and calculate the overlap period once it happened&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is what I have:&lt;/P&gt;
&lt;TABLE width="369"&gt;
&lt;TBODY&gt;
&lt;TR&g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lt;/TD&gt;
&lt;TD&gt;10/14/2017&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;11/3/2017&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need is to create another 4 new variables as follows:&lt;/P&gt;
&lt;P&gt;1. last_taking_date: person 1 had a prescription of drug A and started taking A from 10/7/2017, and this prescription had 5 days supply, so the last taking date for this prescription is 10/11/2017&lt;/P&gt;
&lt;P&gt;2. interval: (I have sorted by ID, then drug, and then start_taking_date) Person 1 had a second prescription of drug A on 10/20/2018, which was 9 days after the first drug A prescription. The third drug A prescription happened 8 days after the last taking date for the second drug A prescription. Person 1 had drug B 9 days earlier than the last day of the third drug A prescription.&lt;/P&gt;
&lt;P&gt;3. Whether_take_AandB_together: person 1 took both drug A and B together from 11/1/2017-11/5/2017&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. How_long: so the overlap period for person 1 is 5 days&lt;/P&gt;
&lt;TABLE width="809"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;ID&lt;/TD&gt;
&lt;TD width="64"&gt;Drug&lt;/TD&gt;
&lt;TD width="136"&gt;start_taking_date&lt;/TD&gt;
&lt;TD width="105"&gt;Days_of_supply&lt;/TD&gt;
&lt;TD width="110"&gt;last_taking_date&lt;/TD&gt;
&lt;TD width="64"&gt;interval&lt;/TD&gt;
&lt;TD width="202"&gt;Whether_take_AandB_together&lt;/TD&gt;
&lt;TD width="64"&gt;how_long&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;10/7/2017&lt;/TD&gt;
&l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&lt;/TD&gt;
&lt;TD rowspan="4"&gt;Y&lt;/TD&gt;
&lt;TD rowspan="4"&gt;16&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;10/6/2017&lt;/TD&gt;
&lt;TD&gt;60&lt;/TD&gt;
&lt;TD&gt;12/7/2017&lt;/TD&gt;
&lt;TD&gt;-2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;10/14/2017&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;10/21/2017&lt;/TD&gt;
&lt;TD&gt;-54&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;11/3/2017&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;11/10/2017&lt;/TD&gt;
&lt;TD&gt;13&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Please pay attention to person 2. Person 2's start taking time for the second prescription of drug A was earlier than it was supposed to be (10/6/2017 is earlier than 10/8/2017), so I still want to calculate as 'NO-early start taking', so the last taking date for the second drug A prescription is 12/7/2017 instead of 12/5/2017. Because the second prescription of drug A covered the drug B's two prescription periods, the overlap period of taking drug A and B 10/14/2017-10/21/2017 and 11/3/2017-11/10/2017, which were 16 days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this is a really complicated project and am having no idea to start framing these time periods and overlap calculation, so any help would be really appreciated!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 23:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680831#M205854</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-01T23:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680838#M205858</link>
      <description>&lt;P&gt;Hiya, this will get you close but my interval differs from yours. I also put in code to only count the overlap duration once but it's a bit messy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	set have;
	end_taking_date = sum(starting_taking_date,Days_of_supply,-1);
run;

proc sort data = have;
	by id drug starting_taking_date end_taking_date;
run;

data have;
	set have;
	lag_id = lag(id);
	lag_start = lag(starting_taking_date);
run;

data have (drop = lag_id lag_start);
	set have;
	nomid = _n_;
	if id = lag_id then
		interval = sum(starting_taking_date,-lag_start);
run;

*get overlap;
proc sql;
	create table want_tmp as
		select  m.nomid, max(p.starting_taking_date,m.starting_taking_date) as share_start_tmp,
			min(p.end_taking_date,m.end_taking_date) as share_end_tmp, p.id as sharer_id
		from have as M, have as P
			where m.drug ne p.drug 
				and m.id = p.id 
				and (P.starting_taking_date &amp;lt;= M.end_taking_date and P.end_taking_date &amp;gt;= M.starting_taking_date);
quit;

proc sql;
	create table want (drop = nomid) as
		select  l.*,coalesce(r.share_start_tmp,l.starting_taking_date) as share_start_tmp   ,
			coalesce(r.share_end_tmp,l.end_taking_date) as share_end_tmp, r.sharer_id
		from have as l left join want_tmp as r
			on l.nomid=r.nomid;
quit;

data want;
	set want;
	format share_start_tmp share_end_tmp ddmmyy10.;
	if sharer_id ne '' then
		overlap_tmp = sum(share_end_tmp,-share_start_tmp,1);
run;

proc sort data =  want;
	by id share_start_tmp share_end_tmp;
run;

data want (drop =  overlap_tmp sharer_id share_start_tmp share_end_tmp);
	set want;
	format share_start share_end end_taking_date mmddyy10.;
	by id share_start_tmp share_end_tmp;
	if sharer_id ne '' and first.share_start_tmp then
		overlap = overlap_tmp;
	if sharer_id ne '' then do;
		share_start = share_start_tmp;
		share_end = share_end_tmp;
	end;
run;

proc sort data =  want;
	by id drug share_start share_end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 00:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680838#M205858</guid>
      <dc:creator>SteveNZ</dc:creator>
      <dc:date>2020-09-02T00:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680855#M205871</link>
      <description>Prescription drug monitoring? Usually you allow 3 days of overlap for prescription refills and don't count those as an overlap....</description>
      <pubDate>Wed, 02 Sep 2020 03:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/680855#M205871</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-02T03:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681154#M206003</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Prescription drug monitoring? Usually you allow 3 days of overlap for prescription refills and don't count those as an overlap....&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Some of my prescriptions vary up to 45 day overlaps (on 90 day scripts). Sometimes there may be a discount and they get filled early to save the insurance company $$, others something esoteric between the pharmacy reschedule requests and my prescribing physician response and may be changing rules about 30 day vs 90 day and ?!? insurance rules.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 21:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681154#M206003</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-02T21:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681235#M206042</link>
      <description>&lt;P&gt;I think this is one of those tasks where it makes the most sense to maintain an array indexed by the date range of your study.&amp;nbsp; Let's say all your prescription supplies are meant to be completely used between 01jan2016 through 31dec2018.&amp;nbsp; Then for drug A populate the elements of the array corresponding to the prescription dates with 1's.&amp;nbsp; After A is exhausted then scan the dates for B in the same array, counting the number of 1's (from A) that are found.&amp;nbsp; That would be total overlap count:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input ID 	Drug :$1. 	start_taking_date :mmddyy8.	Days_of_supply;
 format start_taking_date mmddyy8.;
datalines;
1 	A 	10/7/2017 	5
1 	A 	10/20/2017 	5
1 	A 	11/1/2017 	5
1 	B 	10/27/2017 	10
1 	B 	11/15/2017 	10
2 	A 	10/2/2017 	7
2 	A 	10/6/2017 	60
2 	B 	10/14/2017 	8
2 	B 	11/3/2017 	8
run;

%let history_beg=01jan2016;
%let history_end=31dec2018;

data want (drop=_:);

  /* Read all drug for each ID, just to calculate OVERLAP days */
  do until (last.id);
    set have;
	by id;
	if first.id then overlap=0;

	/* Here's an array indexed from 01jan2016 to 31dec2018 */
	array _calendar {%sysevalf("&amp;amp;history_beg"d):%sysevalf("&amp;amp;history_end"d)}  ;

	/* Loop over the dates for each prescription.  If it's drug A, put a 1 in
	/* the corresponding element in the array.  But if it's a B, count the number
	/* of times the B prescription encounters a 1 in the array */
	do _d=start_taking_date to start_taking_date+days_of_supply-1;
	  if drug='A' then _calendar{_d}=1;
	  else if drug='B' and _calendar{_d}=1 then overlap=overlap+1;;
	end;
  end;

  /* Now that total overlap has been calculated, reread the same id, calculate 
  /* the other vars and output the record */

  do until (last.id);
    set have;
    by id ;
    last_taking_date=start_taking_date+days_of_supply-1;
    format last_taking_date mmddyy8.;
    interval=start_taking_date-lag(last_taking_date);
    if first.id then interval=.;
    output;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This depends on the data being sorted by id/drug/starting_date.&amp;nbsp; Note in the program each ID is read through twice - the first time to calculate overlap, a constant for the id.&amp;nbsp; The second time to calculate the other variables, which are generate within each record, or between each record and its predecessor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, you have interval=-54 for the next-to-last record, but I get -51.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 21:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681235#M206042</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-05T21:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681567#M206171</link>
      <description>&lt;P&gt;Hi Steve,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really appreciate your prompt reply a lot! This is absolutely a comprehensive code to solve my problem. Hats off to the genius!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 08:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681567#M206171</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-04T08:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681568#M206172</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really appreciate your code! It worked for the test codes. But my real data is much larger than the test dataset. I run the code and got and error report from log said that&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Array subscript out of range at line 216 column 34.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a result, there are only parts observations were calculated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me figure out what is going on here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 08:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681568#M206172</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-04T08:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681569#M206173</link>
      <description>&lt;P&gt;Hi, thank you for your kind remind. It is true that there may a short window interval. It is tricky to decide the cut-off point, i.e. should have a few days in between or not. So, what I am going to do is just calculate the overlap (&amp;gt;=1) and the range. I need to make a clinical-meaning decision later for the cut-off point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 08:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681569#M206173</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-04T08:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681570#M206174</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks for discussing my case. I can make the decision for the cut-off point based on the range of overlap I am going to get.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 08:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681570#M206174</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-04T08:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681675#M206211</link>
      <description>&lt;P&gt;This is NOT a data size issue.&amp;nbsp; It is a date-range issue.&amp;nbsp; That's why the message says "array subscript out of range".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The out-of-range means that you have dates before 01jan2016&amp;nbsp; or after 31dec2018, which the defined array can't accommodate.&amp;nbsp; That's why I said " Let's say all your prescription supplies are meant to be completely used between 01jan2016 through 31dec2018."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So just change the two %LET statements to accomodate then entire possible history of your data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 16:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681675#M206211</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-04T16:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681771#M206265</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks for the explanation. I only run the range for start_taking_date. It turns out that my data range is out of range. I have change the %LET statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, when I run the new code, the SAS log said like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY&lt;BR /&gt;expression is missing, zero, or invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am familiar with loop statement, so I have no idea what does this log message mean. Is is because my dataset has some variables with missing values? I don't think there are any variables with any missing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really appreciate your advice a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 23:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681771#M206265</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-04T23:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681774#M206268</link>
      <description>&lt;P&gt;Please show the log.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 02:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681774#M206268</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-05T02:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681828#M206299</link>
      <description>&lt;P&gt;Hi Steve,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking at your code. Could you please explain a little bit for the two proc sql statements? I am quite sure I understand m.varname and p.varname mean in the syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;C&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 18:46:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681828#M206299</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-05T18:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify overlap and calculate overlap time period</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681829#M206300</link>
      <description>&lt;P&gt;Oh, Hi, Steve, actually my calculation for the interval should be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;interval=starting_taking_date - lag_last (not lag_start), &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; and, lag_last=lag(starting_taking_date)&lt;/P&gt;
&lt;P&gt;Does this affect any subsequent syntax?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really appreciate your advice!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 18:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-identify-overlap-and-calculate-overlap-time-period/m-p/681829#M206300</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-09-05T18:54:37Z</dc:date>
    </item>
  </channel>
</rss>

