<?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: Eliminating unneeded admission and discharge dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590689#M169108</link>
    <description>&lt;P&gt;I would need to note overlapping dates so they could be checked individually. Times where the dates overlap should be rare.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be similar to a hotel stay. You check in for a period of time, and in that time you sign up for activities. It would be rare for an activity to start before or to extend past the hotel stay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the dates are&lt;/P&gt;&lt;P&gt;01/01/2019 - 01/31/2019&lt;/P&gt;&lt;P&gt;01/20/2019 - 02/15/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want to look at it individually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the dates are&lt;/P&gt;&lt;P&gt;01/01/2019 - 01//31/2019&lt;/P&gt;&lt;P&gt;01/01/2019 - 01/31/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only care about one of the date ranges. I need to know the person was with us during a time frame, and that is all.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Sep 2019 13:08:17 GMT</pubDate>
    <dc:creator>robertvroom</dc:creator>
    <dc:date>2019-09-22T13:08:17Z</dc:date>
    <item>
      <title>Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590674#M169103</link>
      <description>&lt;P&gt;Where I work, a person might stay for a month, and do a few items within that month. I am trying to figure out only the first and last date of the stay. As an example,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Member 1 has the following cases...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 1 Started 01/01/2019, ended 01/31/2019&lt;/P&gt;&lt;P&gt;Case 2 Started 01/03/2019, ended 01/04/2019&lt;/P&gt;&lt;P&gt;Case 3 Started 01/14/2019, ended 01/18/2019&lt;/P&gt;&lt;P&gt;Case 4 Started 02/15/2019, ended 02/20/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since Cases 2 &amp;amp; 3 took place within the timeframe of case 1, I do not want them to be part of the final data. I only want to return cases 1 and 4 for this member.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I best do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any advice you can provide.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 00:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590674#M169103</guid>
      <dc:creator>robertvroom</dc:creator>
      <dc:date>2019-09-22T00:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590678#M169104</link>
      <description>&lt;P&gt;What happens to cases that overlap in time, say where they start within an earlier case but then go beyond it?&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 01:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590678#M169104</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-09-22T01:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590689#M169108</link>
      <description>&lt;P&gt;I would need to note overlapping dates so they could be checked individually. Times where the dates overlap should be rare.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be similar to a hotel stay. You check in for a period of time, and in that time you sign up for activities. It would be rare for an activity to start before or to extend past the hotel stay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the dates are&lt;/P&gt;&lt;P&gt;01/01/2019 - 01/31/2019&lt;/P&gt;&lt;P&gt;01/20/2019 - 02/15/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would want to look at it individually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the dates are&lt;/P&gt;&lt;P&gt;01/01/2019 - 01//31/2019&lt;/P&gt;&lt;P&gt;01/01/2019 - 01/31/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only care about one of the date ranges. I need to know the person was with us during a time frame, and that is all.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 13:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590689#M169108</guid>
      <dc:creator>robertvroom</dc:creator>
      <dc:date>2019-09-22T13:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590705#M169114</link>
      <description>&lt;P&gt;I'm not entirely convinced this will deal with all cases but feel free to test it. I've also added an overlapping example (case = 5).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input member $ case $ start_date :mmddyy10. end_date :mmddyy10.;
  format start_date end_date date9.; 
datalines;
1 1 01/01/2019 01/31/2019
1 2 01/03/2019 01/04/2019
1 3 01/14/2019 01/18/2019
1 4 02/15/2019 02/20/2019
1 5 02/18/2019 02/22/2019
;
run;

proc sort data = have;
  by member start_date descending end_date;
run;

data want;
  drop SD ED;
  retain SD ED;
  set have;
  by member;
  if first.member then do;
    SD = start_date;
    ED = end_date;
  end;
  else do;
    if start_date &amp;gt;= SD and end_date &amp;lt;= ED then delete; 
  end;
  if start_date &amp;gt; ED then do;
    SD = start_date;
    ED = end_date;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Sep 2019 19:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590705#M169114</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-09-22T19:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590731#M169119</link>
      <description>&lt;P&gt;Thank you SASKiwi, I will try this first thing tomorrow morning.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 13:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590731#M169119</guid>
      <dc:creator>robertvroom</dc:creator>
      <dc:date>2019-09-22T13:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating unneeded admission and discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590773#M169132</link>
      <description>&lt;P&gt;Alternatively, you may try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input member case start_date :mmddyy10. end_date :mmddyy10.;
  format start_date end_date yymmdd10.; 
datalines;
1 1 01/01/2019 01/31/2019
1 2 01/03/2019 01/04/2019
1 3 01/14/2019 01/18/2019
1 4 02/15/2019 02/20/2019
1 5 02/18/2019 02/22/2019
;

proc sql;
select min(start_date)-1, max(end_date)+1
into :d1, :d2
from have;
quit;

data want;
array d_{&amp;amp;d1.:&amp;amp;d2.};
do until(last.member);
	set have; by member;
	do i = start_date to end_date;
		d_{i} = case;
		end;
	end;
do i = &amp;amp;d1.+1 to &amp;amp;d2-1;
	if missing(d_{i-1}) and d_{i} then do;
		start_case = d_{i};
		start_date = i;
		end;
	if d_{i} and missing(d_{i+1}) then do;
		end_case = d_{i};
		end_date = i;
		output;
		end;
	end;
drop d_: i case;
run;

proc print data=want noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;variable &lt;EM&gt;case&lt;/EM&gt; is replaced by &lt;EM&gt;first_case&lt;/EM&gt; and&lt;EM&gt; end_case&lt;/EM&gt; which my differ in some overlap situations.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 00:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Eliminating-unneeded-admission-and-discharge-dates/m-p/590773#M169132</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-23T00:28:18Z</dc:date>
    </item>
  </channel>
</rss>

