<?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 Changing a date variable in three rows in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Changing-a-date-variable-in-three-rows/m-p/82789#M761</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a data set with two date variables, FROM_DTTM and TO_DTTM. There's four rows. For the first three rows, I need to make TO_DTTM be equal to FROM_DTTM plus one second. The fourth row should remain unchanged.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please suggest what kind of code to use for this? I know I can use FIRST. and LAST. to identify the first and last rows, but I don't know about the second and third. Perhaps a while-loop with a count would be best? Alas I remain a bit inexperienced about programming. Please be specific if you can.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2012 08:56:46 GMT</pubDate>
    <dc:creator>EinarRoed</dc:creator>
    <dc:date>2012-10-02T08:56:46Z</dc:date>
    <item>
      <title>Changing a date variable in three rows</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Changing-a-date-variable-in-three-rows/m-p/82789#M761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a data set with two date variables, FROM_DTTM and TO_DTTM. There's four rows. For the first three rows, I need to make TO_DTTM be equal to FROM_DTTM plus one second. The fourth row should remain unchanged.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please suggest what kind of code to use for this? I know I can use FIRST. and LAST. to identify the first and last rows, but I don't know about the second and third. Perhaps a while-loop with a count would be best? Alas I remain a bit inexperienced about programming. Please be specific if you can.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 08:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Changing-a-date-variable-in-three-rows/m-p/82789#M761</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2012-10-02T08:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Changing a date variable in three rows</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Changing-a-date-variable-in-three-rows/m-p/82790#M762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For your very specific case, assuming that you have only 4 rows in the table and assuming that to_dttm and from_dttm contain SAS datetime values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ...&lt;/P&gt;&lt;P&gt;set ...&lt;/P&gt;&lt;P&gt;if _n_&amp;lt;=3 then TO_DTTM=FROM_DTTM+1;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This looks very much like something related to SCD2. If so then TO_DTTM should actually be 1 second less than FROM_DTTM of the NEXT record (and not within the same record).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this about aligning records which got loaded using type 2 loading techniques. Is so let us know and if possible also post your data as the alignment needs then to be done a bit different as shown in the pseudo code I've posted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 09:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Changing-a-date-variable-in-three-rows/m-p/82790#M762</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-10-02T09:05:06Z</dc:date>
    </item>
  </channel>
</rss>

