<?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: How to generate Time Series Date based on this variable previous numbers in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145422#M2351</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that would be a problem.&amp;nbsp; LAG works on the original values when the LAG function is invoked, rather than the subsequent values after manipulating the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a workaround, creating your own stream of values that mimics what the LAG function would do but after manipulating the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; back2 = back1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; back1 = rev;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain back1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rev=. then rev=back2 * exp(num);&lt;/P&gt;&lt;P&gt;&amp;nbsp; * optionally, once the program is working, drop back1 back2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Mar 2014 02:21:45 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2014-03-17T02:21:45Z</dc:date>
    <item>
      <title>How to generate Time Series Date based on this variable previous numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145421#M2350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 14pt; font-family: verdana, geneva;"&gt;Good afternoon,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 14pt; font-family: verdana, geneva;"&gt;I may have a problem to generate new data.&amp;nbsp;&amp;nbsp; As we can see that after Jan-01-2014, Rev is 0. And I would like to fill Rev after Jan-01-2014 by calculating: Rev=lag2(Rev)*Exp(Num). However, there is no data for Rev after Jan-01-2014, so SAS cannot calculate Rev based on the lagged Rev. I tried Retain but it didn't work:(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;TBODY style="font-style: inherit; font-family: inherit;"&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;" width="64"&gt;Num&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;" width="64"&gt;Rev&lt;/TD&gt;&lt;TD class="xl63" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;" width="150"&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;45454&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Jan-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;4&lt;/TD&gt;&lt;TD align="right" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;354353&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Feb-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;7&lt;/TD&gt;&lt;TD align="right" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;25425&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Mar-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;3&lt;/TD&gt;&lt;TD align="right" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;254235&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Jan-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;8&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Feb-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;9&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Mar-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;12&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Jan-01-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="border: 0px; font-style: inherit; font-family: inherit;"&gt;&lt;TD align="right" height="19" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;45&lt;/TD&gt;&lt;TD class="xl64" style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;&lt;/TD&gt;&lt;TD style="padding-right: 4px; padding-left: 4px; border: 0px solid black; font-style: inherit; font-family: inherit;"&gt;Feb-01-2015lag&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Mar 2014 19:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145421#M2350</guid>
      <dc:creator>loving_apples</dc:creator>
      <dc:date>2014-03-16T19:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Date based on this variable previous numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145422#M2351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that would be a problem.&amp;nbsp; LAG works on the original values when the LAG function is invoked, rather than the subsequent values after manipulating the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a workaround, creating your own stream of values that mimics what the LAG function would do but after manipulating the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; back2 = back1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; back1 = rev;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain back1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rev=. then rev=back2 * exp(num);&lt;/P&gt;&lt;P&gt;&amp;nbsp; * optionally, once the program is working, drop back1 back2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 02:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145422#M2351</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-03-17T02:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Date based on this variable previous numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145423#M2352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;Great thanks Astounding, but what if I need lag4 instead of lag2, what I shall change the code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 12:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-generate-Time-Series-Date-based-on-this-variable-previous/m-p/145423#M2352</guid>
      <dc:creator>loving_apples</dc:creator>
      <dc:date>2014-03-17T12:58:54Z</dc:date>
    </item>
  </channel>
</rss>

