<?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: Adding dates between incident-dates in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-dates-between-incident-dates/m-p/30221#M7137</link>
    <description>You could use the lag function to generate a start and end data variable.&lt;BR /&gt;
&lt;BR /&gt;
Something like this might work-- but I'm not sure what you want to do with single incident (like 3 A 05-02-2008)&lt;BR /&gt;
&lt;BR /&gt;
Data a;&lt;BR /&gt;
input ID  Incident txt  startDate;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 A 01-01-2008&lt;BR /&gt;
1 A 05-03-2008&lt;BR /&gt;
1 B 08-03-2008 &lt;BR /&gt;
2 B 02-02-2008&lt;BR /&gt;
2 F 03-04-2008&lt;BR /&gt;
3 A 05-02-2008&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort; by id startdate;&lt;BR /&gt;
&lt;BR /&gt;
data b;&lt;BR /&gt;
  set a;&lt;BR /&gt;
  by id;&lt;BR /&gt;
&lt;BR /&gt;
  enddate=lag(startdate);&lt;BR /&gt;
&lt;BR /&gt;
  if first.id then delete; /* or if first.id then enddate = .;&lt;BR /&gt;
run;</description>
    <pubDate>Wed, 09 Jul 2008 23:28:15 GMT</pubDate>
    <dc:creator>LAP</dc:creator>
    <dc:date>2008-07-09T23:28:15Z</dc:date>
    <item>
      <title>Adding dates between incident-dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-dates-between-incident-dates/m-p/30220#M7136</link>
      <description>All,&lt;BR /&gt;
&lt;BR /&gt;
I've got a table with multiple variables, an incident date and id's which can occur more than once. The incident date changes every time an incident occur. Like:&lt;BR /&gt;
&lt;BR /&gt;
ID | Incident txt || Incident Date&lt;BR /&gt;
1         A             01-01-2008&lt;BR /&gt;
1         A             05-03-2008&lt;BR /&gt;
1         B             08-03-2008    &lt;BR /&gt;
2         B             02-02-2008&lt;BR /&gt;
2         F             03-04-2008&lt;BR /&gt;
3         A             05-02-2008&lt;BR /&gt;
&lt;BR /&gt;
Before, I had an table where on 1 row I've had an start and an end date, and with the statement: "do date = start_date to end_date by 1", it was extremeley simple to create a table with all the dates since between incidents for every ID (and later on, filling in the missing values which wasn't really a problem).&lt;BR /&gt;
&lt;BR /&gt;
But now, when the 'end' date is on the following row, I have no idea how to create a table with all the dates between incidents per ID!&lt;BR /&gt;
&lt;BR /&gt;
Anyone have any idea? Thanks in advance!</description>
      <pubDate>Wed, 09 Jul 2008 15:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-dates-between-incident-dates/m-p/30220#M7136</guid>
      <dc:creator>Wouter</dc:creator>
      <dc:date>2008-07-09T15:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding dates between incident-dates</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-dates-between-incident-dates/m-p/30221#M7137</link>
      <description>You could use the lag function to generate a start and end data variable.&lt;BR /&gt;
&lt;BR /&gt;
Something like this might work-- but I'm not sure what you want to do with single incident (like 3 A 05-02-2008)&lt;BR /&gt;
&lt;BR /&gt;
Data a;&lt;BR /&gt;
input ID  Incident txt  startDate;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 A 01-01-2008&lt;BR /&gt;
1 A 05-03-2008&lt;BR /&gt;
1 B 08-03-2008 &lt;BR /&gt;
2 B 02-02-2008&lt;BR /&gt;
2 F 03-04-2008&lt;BR /&gt;
3 A 05-02-2008&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort; by id startdate;&lt;BR /&gt;
&lt;BR /&gt;
data b;&lt;BR /&gt;
  set a;&lt;BR /&gt;
  by id;&lt;BR /&gt;
&lt;BR /&gt;
  enddate=lag(startdate);&lt;BR /&gt;
&lt;BR /&gt;
  if first.id then delete; /* or if first.id then enddate = .;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 09 Jul 2008 23:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-dates-between-incident-dates/m-p/30221#M7137</guid>
      <dc:creator>LAP</dc:creator>
      <dc:date>2008-07-09T23:28:15Z</dc:date>
    </item>
  </channel>
</rss>

