<?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: Propagate a row untill next date value and continue till certain date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455227#M115134</link>
    <description>Hi Kurtbesmer&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply. I will try the solution&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Sandhya S&lt;BR /&gt;</description>
    <pubDate>Wed, 18 Apr 2018 14:48:37 GMT</pubDate>
    <dc:creator>Sandy10</dc:creator>
    <dc:date>2018-04-18T14:48:37Z</dc:date>
    <item>
      <title>Propagate a row untill next date value and continue till certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455101#M115096</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a dataset as below. I would like to retain the full row untill there is a change in the date value and continue the same till a particular date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data bal_det;&lt;BR /&gt;informat st_dt open_dt date9.;&lt;BR /&gt;format st_dt open_dt date9.;&lt;BR /&gt;input id $ st_dt open_dt bal;&lt;BR /&gt;cards;&lt;/P&gt;&lt;P&gt;1 19SEP2017 19SEP2017 10000&lt;BR /&gt;1 19DEC2017 19SEP2017 0&lt;BR /&gt;3 29DEC2017 29DEC2017 35000&lt;BR /&gt;3 30DEC2017 29DEC2017 0&lt;BR /&gt;3 01JAN2018 29DEC2017 1000&lt;BR /&gt;3 10JAN2018 29DEC2017 30000&lt;BR /&gt;3 27FEB2018 29DEC2017 0&lt;BR /&gt;3 10MAR2018 29DEC2017 1000&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id st_dt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; open_dt&amp;nbsp; &amp;nbsp; &amp;nbsp;bal&lt;BR /&gt;1 19SEP2017 19SEP2017 10000&lt;BR /&gt;1 20SEP2017 19SEP2017 10000&lt;BR /&gt;1 21SEP2017 19SEP2017 10000&lt;BR /&gt;1 .....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10000&lt;BR /&gt;1 18DEC2017 19SEP2017 10000&lt;BR /&gt;1 19DEC2017 19SEP2017 0&lt;BR /&gt;1 20DEC2017 19SEP2017 0&lt;BR /&gt;1 21DEC2017 19SEP2017 0&lt;BR /&gt;1 .....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;1 31MAR2018 19SEP2017 0&lt;BR /&gt;3 29DEC2017 29DEC2017 35000&lt;BR /&gt;3 30DEC2017 29DEC2017 0&lt;BR /&gt;3 31DEC2017 29DEC2017 0&lt;BR /&gt;3 01JAN2018 29DEC2017 1000&lt;BR /&gt;3 02JAN2018 29DEC2017 1000&lt;BR /&gt;3 ....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&lt;BR /&gt;3 09JAN2018 29DEC2017 1000&lt;BR /&gt;3 10JAN2018 29DEC2017 30000&lt;BR /&gt;3 11JAN2018 29DEC2017 30000&lt;BR /&gt;3 12JAN2018 29DEC2017 30000&lt;BR /&gt;3 ....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30000&lt;BR /&gt;3 26FEB2018 29DEC2017 30000&lt;BR /&gt;3 27FEB2018 29DEC2017 0&lt;BR /&gt;3 28FEB2018 29DEC2017 0&lt;BR /&gt;3 ...&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;3 09MAR2018 29DEC2017 0&lt;BR /&gt;3 ....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;3 09MAR2018 29DEC2017 0&lt;BR /&gt;3 10MAR2018 29DEC2017 1000&lt;BR /&gt;3 .....&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&lt;BR /&gt;3 31MAR2018 29DEC2017 1000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i USED ONE OF THE CODE GIVEN IN THIS COMMUNITY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Want;&lt;/P&gt;&lt;P&gt;Informat id&lt;BR /&gt;st_dt&lt;BR /&gt;bal&lt;BR /&gt;open_dt&lt;BR /&gt;;&lt;BR /&gt;format st_dt date9.;&lt;BR /&gt;format open_dt date9.;&lt;/P&gt;&lt;P&gt;Retain prevST_TS .&lt;BR /&gt;prevBal&lt;BR /&gt;prevDOD&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;Set cohort_fd(Rename=(st_dt=xst_dt bal=xbal open_dt=xopen_dt));&lt;BR /&gt;By id&lt;BR /&gt;xst_dt&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If NOT First.id Then&lt;BR /&gt;Do;&lt;BR /&gt;StartDate=prevST_TS;&lt;BR /&gt;If Last.id Then&lt;BR /&gt;Do;&lt;BR /&gt;StopDate=xst_dt;&lt;BR /&gt;End;&lt;BR /&gt;Else&lt;BR /&gt;Do;&lt;BR /&gt;StopDate=xst_dt-1;&lt;BR /&gt;End;&lt;/P&gt;&lt;P&gt;bal=prevBal;&lt;BR /&gt;open_dt=prevDOD;&lt;BR /&gt;Do st_dt=StartDate To StopDate;&lt;BR /&gt;Output;&lt;BR /&gt;End;&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;prevST_TS=xst_dt;&lt;BR /&gt;prevBal=xbal;&lt;BR /&gt;prevDOD=xopen_dt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;format st_dt date9.;&lt;BR /&gt;format open_dt date9.;&lt;BR /&gt;format prevST_TS date9.;&lt;BR /&gt;format prevDOD date9.;&lt;BR /&gt;format xst_dt date9.;&lt;BR /&gt;format xopen_dt date9.;&lt;BR /&gt;&lt;BR /&gt;Drop prevST_TS&lt;BR /&gt;prevBal&lt;BR /&gt;prevDOD&lt;BR /&gt;StartDate&lt;BR /&gt;StopDate&lt;BR /&gt;xst_dt&lt;BR /&gt;xbal&lt;BR /&gt;xopen_dt&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output :&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Issue is, if last.id date balance value is 100, instead&amp;nbsp;of 100, it takes the previous value which was retained .&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2. I havent included the data to be retained till mar 2018 (which I dont know how to )&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help on above 2 queries.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Sandhya S&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 11:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455101#M115096</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2018-04-18T11:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Propagate a row untill next date value and continue till certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455115#M115097</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let maxdate=%sysfunc(inputn(31mar2018,date9.));

data want;
merge
  bal_det
  bal_det ( /* "look ahead" into the next row */
    firstobs=2
    keep=st_dt id
    rename=(id=newid st_dt=newdate)
  )
;
output;
if id = newid
then do st_dt = st_dt + 1 to newdate - 1;
  output;
end;
else do st_dt = st_dt + 1 to &amp;amp;maxdate;
  output;
end;
drop newid newdate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Apr 2018 11:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455115#M115097</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-18T11:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Propagate a row untill next date value and continue till certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455185#M115110</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Doesnt Merge take time to process? Becausr dataset will be containing&lt;BR /&gt;around 60K records. Kindly advise.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Sandhya S&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Apr 2018 14:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455185#M115110</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2018-04-18T14:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Propagate a row untill next date value and continue till certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455211#M115125</link>
      <description>&lt;P&gt;Since this "merge" merges the dataset with itself, just one observation offset, it is physically one sequential read (the second read of a dataset page happens from the cache), so no problem. And 60K obs (unless you have a monstrous observation size) are processed in less than a few seconds on any halfway current system.&lt;/P&gt;
&lt;P&gt;If you experience problems, we need to know more about the dataset in question (eg a proc contents output).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have to create a LOT of new observations because of the way the data has gaps, then the write of the output will be your determining factor, no way around that.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 14:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455211#M115125</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-18T14:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Propagate a row untill next date value and continue till certain date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455227#M115134</link>
      <description>Hi Kurtbesmer&lt;BR /&gt;&lt;BR /&gt;Thanks for your reply. I will try the solution&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Sandhya S&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Apr 2018 14:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Propagate-a-row-untill-next-date-value-and-continue-till-certain/m-p/455227#M115134</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2018-04-18T14:48:37Z</dc:date>
    </item>
  </channel>
</rss>

