<?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 Data, based on this variable's lag numbers in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145596#M9366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An easy way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; back2 = lag(rev);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if rev=. then rev=back2 * exp(num);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By placing the LAG function before the SET statement, it retrieves 2 observations prior, and also reflects changes that were made by the data manipulation statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To go back 4 observations, the equivalent of lag4, use&lt;/P&gt;&lt;P&gt;back4 = lag3(rev);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Mar 2014 13:09:31 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2014-03-17T13:09:31Z</dc:date>
    <item>
      <title>How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145590#M9360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: verdana, geneva;"&gt;Good afternoon, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="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="width: 278px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="64"&gt;Num&lt;/TD&gt;&lt;TD width="64"&gt;Rev&lt;/TD&gt;&lt;TD class="xl63" width="150"&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;3&lt;/TD&gt;&lt;TD align="right"&gt;45454&lt;/TD&gt;&lt;TD class="xl64"&gt;Jan-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;354353&lt;/TD&gt;&lt;TD class="xl64"&gt;Feb-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;7&lt;/TD&gt;&lt;TD align="right"&gt;25425&lt;/TD&gt;&lt;TD class="xl64"&gt;Mar-01-2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;3&lt;/TD&gt;&lt;TD align="right"&gt;254235&lt;/TD&gt;&lt;TD class="xl64"&gt;Jan-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;8&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;/TD&gt;&lt;TD&gt;Feb-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;9&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;/TD&gt;&lt;TD&gt;Mar-01-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;12&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;/TD&gt;&lt;TD&gt;Jan-01-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="19"&gt;45&lt;/TD&gt;&lt;TD class="xl64"&gt;&lt;/TD&gt;&lt;TD&gt;Feb-01-2015&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:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145590#M9360</guid>
      <dc:creator>loving_apples</dc:creator>
      <dc:date>2014-03-16T19:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145591#M9361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does your data look like versus what you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is the above data set what you want, or what you have?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Mar 2014 19:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145591#M9361</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-16T19:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145592#M9362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;thanks Reeza,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;what I have is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border: 0px; font-size: 12.727272033691406px; 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;&lt;SPAN style="font-size: 14pt;"&gt;Num&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Rev&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Date&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;3&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;45454&lt;/SPAN&gt;&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;SPAN style="font-size: 14pt;"&gt;Jan-01-2013&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;4&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;354353&lt;/SPAN&gt;&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;SPAN style="font-size: 14pt;"&gt;Feb-01-2013&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;7&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;25425&lt;/SPAN&gt;&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;SPAN style="font-size: 14pt;"&gt;Mar-01-2013&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;3&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;254235&lt;/SPAN&gt;&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;SPAN style="font-size: 14pt;"&gt;Jan-01-2014&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;8&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Feb-01-2014&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;9&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Mar-01-2014&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;12&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Jan-01-2015&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;45&lt;/SPAN&gt;&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;&lt;SPAN style="font-size: 14pt;"&gt;Feb-01-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt;"&gt;And what I want is following, with conditions: 1) When Date&amp;lt;=Jan-01-2014, Rev_r=Rev； 2） When Date&amp;gt;Jan-01-2014, Rev_r=lag2(Rev_r) * exp(Num)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE height="220.18181824684143" style="width: 417.18181824684143px; height: 220.18181824684143px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Num&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Rev&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Date&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Rev_r&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;45454&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Jan-01-2013&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;45454&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;4&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;354353&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Feb-01-2013&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;354353&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;7&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;25425&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Mar-01-2013&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;25425&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;3&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;254235&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Jan-01-2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;254235&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;8&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Feb-01-2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;75790856.82&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;9&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Mar-01-2014&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;2060087542&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;12&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Jan-01-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;1.23353E+13&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;45&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;Feb-01-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 14pt;"&gt;7.19677E+28&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Mar 2014 20:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145592#M9362</guid>
      <dc:creator>loving_apples</dc:creator>
      <dc:date>2014-03-16T20:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145593#M9363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an idea, seems working for your present data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Num&amp;nbsp;&amp;nbsp; Rev&amp;nbsp;&amp;nbsp; Date :&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;anydtdte20.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 45454 Jan-01-2013&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 354353&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb-01-2013&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25425 Mar-01-2013&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 254235&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan-01-2014&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb-01-2014&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mar-01-2014&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan-01-2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;45&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feb-01-2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; rv(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;_temporary_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; rvr(&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;:&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;_temporary_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_ &amp;gt;= &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; rvr(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;))=rv(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)) * exp(num);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp; rv(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)) = coalesce(rev, rvr(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date &amp;lt; = &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;'01jan2014'd&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Rev_r = rv(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Rev_r=rvr(mod(_n_,&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Mar 2014 22:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145593#M9363</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-03-16T22:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145594#M9364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The trick is to use the proper lag at the proper place in the datastep (i.e. after &lt;STRONG&gt;Rev&lt;/STRONG&gt; gets its value):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input Num Rev Date :ANYDTDTE11.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;format date date9.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3 45454 Jan-01-2013&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4 354353 Feb-01-2013&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;7 25425 Mar-01-2013&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3 254235 Jan-01-2014&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;8 . Feb-01-2014&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;9 . Mar-01-2014&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;12 . Jan-01-2015&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;45 . Feb-01-2015&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;retain lag2Rev;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if missing(Rev) then Rev = lag2Rev * exp(Num);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lag2Rev = lag(Rev);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop lag2Rev;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=want noobs; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 01:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145594#M9364</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-03-17T01:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145595#M9365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;thank you Hai Kuo, but could you do me a favor to tell me what is condition statement: if _n_&amp;gt;3 here means? and what if Rev_r=lag4(Rev_r) * exp(Num) instead of lag2, how shall I change the code?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 12:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145595#M9365</guid>
      <dc:creator>loving_apples</dc:creator>
      <dc:date>2014-03-17T12:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145596#M9366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An easy way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; back2 = lag(rev);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if rev=. then rev=back2 * exp(num);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By placing the LAG function before the SET statement, it retrieves 2 observations prior, and also reflects changes that were made by the data manipulation statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To go back 4 observations, the equivalent of lag4, use&lt;/P&gt;&lt;P&gt;back4 = lag3(rev);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 13:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145596#M9366</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-03-17T13:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate Time Series Data, based on this variable's lag numbers</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145597#M9367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An easy tweak will do:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array rv(0:3) _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array rvr(0:3) _temporary_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ &amp;gt;= 5 then rvr(mod(_n_,4))=rv(mod(_n_,4)) * exp(num);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rv(mod(_n_,4)) = coalesce(rev, rvr(mod(_n_,4)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if date &amp;lt; = '01jan2014'd then Rev_r = rv(mod(_n_,4));&lt;/P&gt;&lt;P&gt;&amp;nbsp; else Rev_r=rvr(mod(_n_,4));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I would recommend those solutions suggested by PG or Astounding, for the sake of easier coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/How-to-generate-Time-Series-Data-based-on-this-variable-s-lag/m-p/145597#M9367</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-03-17T14:10:47Z</dc:date>
    </item>
  </channel>
</rss>

