<?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: calculated delay between dates with condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/709150#M218010</link>
    <description>&lt;P&gt;The first thing you need to do is put your data into a usable structure, or avoid the transposition to wide if that happened further up in your process.&lt;/P&gt;
&lt;P&gt;Search for "double transpose" here, or with Google.&lt;/P&gt;</description>
    <pubDate>Sun, 03 Jan 2021 16:10:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-01-03T16:10:14Z</dc:date>
    <item>
      <title>calculated delay between dates with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708904#M217886</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input client $ date1 date9. event1 $
    date2 date9. event2 $
    date3 date9. event3 $
    imp1: date9. imp2: date9. imp3: date9. ;
  format date: imp: date9. ;
datalines ;
12345 01JAN2020 CREATION 01APR2020 CREATION 01JUL2020 PROLONGATION 01MAR2020 01MAY2020 01SEP2020
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;happy new year !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each imp, I would like to calculate the duration between the imp date and the greatest event among the creation event&lt;/P&gt;
&lt;P&gt;thanks a lot in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#ff0000"&gt;delay1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; of the imp1 = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; = from january to mars (event 1 is the begining)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;delay2 of the imp2 = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; = from april to may (event&amp;nbsp;2 is the begining)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;delay3 of the imp3 = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; = from april to september (event&amp;nbsp;2 is the begining, event3 is ignored because not creation)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 19:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708904#M217886</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2020-12-31T19:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: calculated delay between dates with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708906#M217888</link>
      <description>&lt;P&gt;What the heck is a "greatest event"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get differences between date values by either subtracting, which gives days as a result, or the INTCK function to get counts of other types of intervals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since Imp1 is a date it is very unlikely to every be 2 as in&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#ff0000"&gt;delay1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; of the imp1 = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; = from january to mars (event 1 is the begining)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;so you need to provide a bit more description of your problem and show what the actual result of the data given should be.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;BTW, best is not to have blank lines in DATALINES block&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 16:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708906#M217888</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-31T16:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: calculated delay between dates with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708934#M217907</link>
      <description>&lt;P&gt;It might be easier if your data was more normalized. Perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input client event :$20. date :date. ;
  format date date9.;
cards;
12345 CREATION       01JAN2020
12345 CREATION       01APR2020
12345 PROLONGATION   01JUL2020
12345 IMPLEMENTATION 01MAR2020
12345 IMPLEMENTATION 01MAY2020
12345 IMPLEMENTATION 01SEP2020
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So given data in this form what output would you want?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 19:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/708934#M217907</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-31T19:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: calculated delay between dates with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/709146#M218008</link>
      <description>&lt;P&gt;Here is a way to get what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array delays(*) 8 delay1-delay3;
  array dates(*) 8 date1-date3;
  array events(*) $8 event1-event3;
  array imps(*) 8 imp1-imp3;
  do _N_=1 to dim(dates);
    if events(_N_)='CREATION' then
      _created=dates(_N_);
    delays(_N_)=intck('month',_created,imps(_N_));
    end;
  drop _created;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jan 2021 13:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/709146#M218008</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-01-03T13:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: calculated delay between dates with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/709150#M218010</link>
      <description>&lt;P&gt;The first thing you need to do is put your data into a usable structure, or avoid the transposition to wide if that happened further up in your process.&lt;/P&gt;
&lt;P&gt;Search for "double transpose" here, or with Google.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 16:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculated-delay-between-dates-with-condition/m-p/709150#M218010</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-03T16:10:14Z</dc:date>
    </item>
  </channel>
</rss>

