<?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: Calculate duration when there are multiple dates in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275535#M7730</link>
    <description>&lt;P&gt;If you want to go to a long (vertical) data structure and calculate durations :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array _d date1-date50;
do i = 1 to dim(_d);
	date = _d{i};
	if not missing(date) then do;
		call missing(duration);
		if i &amp;gt; 1 then if not missing(_d{i-1}) then 
			duration = intck("DAY", _d{i-1}, date);
		output;
		end;
	end;
drop i date1-date50;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Jun 2016 22:36:41 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-06-06T22:36:41Z</dc:date>
    <item>
      <title>Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275530#M7728</link>
      <description>&lt;P&gt;How do I calculate duration when I have multiple dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example -&lt;/P&gt;&lt;P&gt;Peson ID &amp;nbsp; &amp;nbsp;Diagnosis Date1 Date2 Date3......Date50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to calculate the difference between Date50 and Date49, Date49 and Date 48 and so on. Is wide data the way to go for this estimation or should my data be vertical instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 21:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275530#M7728</guid>
      <dc:creator>batulelec</dc:creator>
      <dc:date>2016-06-06T21:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275532#M7729</link>
      <description>&lt;P&gt;The first thing is to have the dates as SAS date values, are they?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What the intervals will be used for would likely determine the final format.&lt;/P&gt;
&lt;P&gt;If the data is currently in wide form with the values as SAS dates then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; array dates date1-date50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; array dur&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; duration1-duration-50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do i = 1 to (dim (dates) - 1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; duration[i+1] = dates[i+1] - dates[i];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;duration would be in days. duration1 is basically a place holder to keep the references easy to manage.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2016 22:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275532#M7729</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-06T22:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275535#M7730</link>
      <description>&lt;P&gt;If you want to go to a long (vertical) data structure and calculate durations :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array _d date1-date50;
do i = 1 to dim(_d);
	date = _d{i};
	if not missing(date) then do;
		call missing(duration);
		if i &amp;gt; 1 then if not missing(_d{i-1}) then 
			duration = intck("DAY", _d{i-1}, date);
		output;
		end;
	end;
drop i date1-date50;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Jun 2016 22:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275535#M7730</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-06T22:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275539#M7731</link>
      <description>&lt;P&gt;Remember, if you have 50 days you have only 49 durations.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 00:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275539#M7731</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-07T00:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275687#M7739</link>
      <description>&lt;P&gt;Thank you, this works!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 14:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275687#M7739</guid>
      <dc:creator>batulelec</dc:creator>
      <dc:date>2016-06-07T14:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275690#M7741</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Yes, you are correct - thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 14:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275690#M7741</guid>
      <dc:creator>batulelec</dc:creator>
      <dc:date>2016-06-07T14:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275691#M7742</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 14:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275691#M7742</guid>
      <dc:creator>batulelec</dc:creator>
      <dc:date>2016-06-07T14:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration when there are multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275730#M7743</link>
      <description>&lt;P&gt;Hello batulelec,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the SAS Data Management Community. I'm glad you found some useful info! If one of the replies was the exact solution to your problem, can you "Accept it as a solution"? Or if one was particularly helpful, feel free to "Like" it. This will help other community members who may run into the same issue know what worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Laura&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2016 16:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Calculate-duration-when-there-are-multiple-dates/m-p/275730#M7743</guid>
      <dc:creator>lauralawton</dc:creator>
      <dc:date>2016-06-07T16:13:34Z</dc:date>
    </item>
  </channel>
</rss>

