<?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 Finding the first date variable 90 days out from another date variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623663#M183646</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have identified claims for a specific injury type and the injury can reoccur on different dates. My data was originally set up this way with multiple rows per person (each row is a claim for each injury).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; admission_date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;03Feb2009&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05Feb2009&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;14Jun2009&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25Oct2011&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19Sept2008&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04Jan2010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I subsequently transposed the data using the code below since I need the data in wide format for subsequent analyses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*transpose so that multiple injury admission dates are separate variables;&lt;BR /&gt;proc sort data=inj_all; by id; run;&lt;BR /&gt;proc transpose data=in_all out=inj_wide_dt (drop=_NAME_ _LABEL_)&lt;BR /&gt;prefix=injury_date;&lt;BR /&gt;var admission_date;&lt;BR /&gt;by id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data now looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;injury_date1&amp;nbsp; injury_date2&amp;nbsp; injury_date3&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; 03Feb2009&amp;nbsp; &amp;nbsp;05Feb2009&amp;nbsp; &amp;nbsp;14Jun2009&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; 25Oct2011&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; 19Sep2008&amp;nbsp; 04Jan2010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those who have more than one injury date, I need to take the first date that is more than 90 days out from the first injury date...so in the case of ID 1, that would be 14Jun2009 since that is more than 90 days past 03Feb2009 and for ID 3, that would be 04Jan2010. Is there a way to do this in SAS? Ultimately, I just need to create an indicator, 1 if there is a date &amp;gt;90 days from injury_date1, and 0 otherwise. Any help provided would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best!&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2020 19:31:14 GMT</pubDate>
    <dc:creator>silversta</dc:creator>
    <dc:date>2020-02-10T19:31:14Z</dc:date>
    <item>
      <title>Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623663#M183646</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have identified claims for a specific injury type and the injury can reoccur on different dates. My data was originally set up this way with multiple rows per person (each row is a claim for each injury).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; admission_date&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;03Feb2009&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05Feb2009&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;14Jun2009&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;25Oct2011&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19Sept2008&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;04Jan2010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I subsequently transposed the data using the code below since I need the data in wide format for subsequent analyses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*transpose so that multiple injury admission dates are separate variables;&lt;BR /&gt;proc sort data=inj_all; by id; run;&lt;BR /&gt;proc transpose data=in_all out=inj_wide_dt (drop=_NAME_ _LABEL_)&lt;BR /&gt;prefix=injury_date;&lt;BR /&gt;var admission_date;&lt;BR /&gt;by id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data now looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;injury_date1&amp;nbsp; injury_date2&amp;nbsp; injury_date3&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; 03Feb2009&amp;nbsp; &amp;nbsp;05Feb2009&amp;nbsp; &amp;nbsp;14Jun2009&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; 25Oct2011&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; 19Sep2008&amp;nbsp; 04Jan2010&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those who have more than one injury date, I need to take the first date that is more than 90 days out from the first injury date...so in the case of ID 1, that would be 14Jun2009 since that is more than 90 days past 03Feb2009 and for ID 3, that would be 04Jan2010. Is there a way to do this in SAS? Ultimately, I just need to create an indicator, 1 if there is a date &amp;gt;90 days from injury_date1, and 0 otherwise. Any help provided would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 19:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623663#M183646</guid>
      <dc:creator>silversta</dc:creator>
      <dc:date>2020-02-10T19:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623664#M183647</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID      admission_date :date9.;
format admission_date date9.;
cards;
1       03Feb2009
1       05Feb2009
1       14Jun2009
2       25Oct2011
3       19Sep2008
3       04Jan2010
;

proc sql;
create table want as
select a.*,intck('days',m,admission_date)&amp;gt;90 as indicator
from have a left join (select id,min(admission_date) as m  from have group by id)b
on a.id=b.id
order by id,admission_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;More concised form of the above would be remerge automatically like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *,intck('days',min(admission_date),admission_date)&amp;gt;90 as indicator
from have
group by id
order by  id,admission_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 19:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623664#M183647</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-10T19:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623779#M183688</link>
      <description>&lt;P&gt;Creating the indicator in a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID      admission_date :date9.;
format admission_date date9.;
cards;
1       03Feb2009
1       05Feb2009
1       14Jun2009
2       25Oct2011
3       19Sep2008
3       04Jan2010
;

proc transpose data=have out=wide (drop=_NAME_)
prefix=injury_date;
var admission_date;
by id;
run;

data ind (keep=id indicator);
set have;
by id;
retain start;
if first.id then start = admission_date;
if last.id;
indicator = admission_date ge start + 90;
run;

data want;
merge
  wide
  ind
;
by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 07:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623779#M183688</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-11T07:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623897#M183726</link>
      <description>Maybe @silvestra, you should add another example to the data you have posted, so that it is not always the last date to select.</description>
      <pubDate>Tue, 11 Feb 2020 16:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623897#M183726</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-02-11T16:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623902#M183727</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311492"&gt;@silversta&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, a simple solution would be a data step instead of transpose and/or proc sql; Retain first date for each ID and check following records against that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID admission_date :date9.;
	format admission_date date9.;
	cards;
1       03Feb2009
1       05Feb2009
1       14Jun2009
2       25Oct2011
3       19Sep2008
3       04Jan2010
;
run;

data want (drop=firstdate); 
	set have;
	by ID;
	retain firstdate;
	if first.ID then firstdate = admission_date;
	if admission_date &amp;gt; firstdate + 90 then flag = 1;
	else flag = 0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="dcheck.gif" style="width: 306px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36017i49E408724CE82020/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcheck.gif" alt="dcheck.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 16:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/623902#M183727</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-02-11T16:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the first date variable 90 days out from another date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/638724#M189949</link>
      <description>&lt;P&gt;Thank you all for your help! This worked marvelously!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 16:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-first-date-variable-90-days-out-from-another-date/m-p/638724#M189949</guid>
      <dc:creator>silversta</dc:creator>
      <dc:date>2020-04-09T16:14:15Z</dc:date>
    </item>
  </channel>
</rss>

