<?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: replacing actual date to expected date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496261#M131197</link>
    <description>&lt;P&gt;Not tested as no test data in the form of a datastep:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array d{4} date_:;
  array d_e{4} date_1_expected date_2_expected date_3_expected date_4_expected;
  do i=1 to 3;
    if d{i}=. and d{i+1} ne . then d{i}=d_e{i};
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Note, that this isn't run for the last element as no +1.&amp;nbsp; Also note, you have to type in the variables for the expected as you have made it as hard as possible by the naming convetion.&amp;nbsp; Use prefixed variable names to make your life easier like with date_X.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Sep 2018 15:12:59 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-17T15:12:59Z</dc:date>
    <item>
      <title>replacing actual date to expected date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496257#M131195</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to code the following:&lt;/P&gt;&lt;P&gt;If date 1 is not filled in, but the subsequent date is filled in then use EXPECTED date for that date. Same for others (date 4 is always filled in).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;subject_id&lt;/TD&gt;&lt;TD&gt;date_1&lt;/TD&gt;&lt;TD&gt;date_1_expected&lt;/TD&gt;&lt;TD&gt;date_2&lt;/TD&gt;&lt;TD&gt;date_2_expected&lt;/TD&gt;&lt;TD&gt;date_3&lt;/TD&gt;&lt;TD&gt;date_3_expected&lt;/TD&gt;&lt;TD&gt;date_4&lt;/TD&gt;&lt;TD&gt;date_4_expected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1111&lt;/TD&gt;&lt;TD&gt;1/1/2016&lt;/TD&gt;&lt;TD&gt;1/2/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/7/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/12/2016&lt;/TD&gt;&lt;TD&gt;1/17/2016&lt;/TD&gt;&lt;TD&gt;1/17/2016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2222&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/5/2017&lt;/TD&gt;&lt;TD&gt;1/9/2018&lt;/TD&gt;&lt;TD&gt;1/10/2017&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/15/2017&lt;/TD&gt;&lt;TD&gt;1/20/2017&lt;/TD&gt;&lt;TD&gt;1/20/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3333&lt;/TD&gt;&lt;TD&gt;1/4/2018&lt;/TD&gt;&lt;TD&gt;1/4/2018&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/9/2018&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1/14/2018&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;1/18/2018&lt;/TD&gt;&lt;TD&gt;1/19/2018&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I have the following code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;&amp;nbsp;select coalesce(&lt;SPAN&gt;date_1&lt;/SPAN&gt;,&lt;SPAN&gt;date_1_expected&lt;/SPAN&gt;) as&amp;nbsp;date_1_new&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;&amp;nbsp; from dataset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;but I would like to add in the constraint that next date is filled&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial',sans-serif;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 14:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496257#M131195</guid>
      <dc:creator>radhikaa4</dc:creator>
      <dc:date>2018-09-17T14:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: replacing actual date to expected date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496261#M131197</link>
      <description>&lt;P&gt;Not tested as no test data in the form of a datastep:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array d{4} date_:;
  array d_e{4} date_1_expected date_2_expected date_3_expected date_4_expected;
  do i=1 to 3;
    if d{i}=. and d{i+1} ne . then d{i}=d_e{i};
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Note, that this isn't run for the last element as no +1.&amp;nbsp; Also note, you have to type in the variables for the expected as you have made it as hard as possible by the naming convetion.&amp;nbsp; Use prefixed variable names to make your life easier like with date_X.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 15:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496261#M131197</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-17T15:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: replacing actual date to expected date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496390#M131273</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;coalesce(date_1, &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;case&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date_2 is missing &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date_2_expected &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; date_1 format=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 20:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-actual-date-to-expected-date/m-p/496390#M131273</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-09-17T20:03:48Z</dc:date>
    </item>
  </channel>
</rss>

