<?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 base sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85003#M18286</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a numeric column REQ_ORD and need to calculate "NF" column on group variables PROD, CUST, PER_DT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In below example, need to pass dynamic date value '01-JUL-2013' for PER_DT column. need to consider previous 3 records(01-APR-2013, 01-MAY-2013, 01-JUN-2013) from dynamic date value('01-JUL-2013')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mentioned New calculated column "NF"&amp;nbsp; with calculation description(NF description). To calculate NF for 01-Jul-2013, Avg of previous 3 records (01-APR-2013,01-MAY-2013, 01-JUN-2013) of REQ_ORD, To calculate NF for 01-Aug-2013, Avg of first 2 records(01-MAY-2013, 01-JUN-2013) of REQ_ORD and Third record(01-JUL-2013) of NF, To calculate NF for 01-Sep-2013, Avg of first record(01-Jun-2013) of REQ_ORD and last two records (01-JUL-2013, 01-AUG-2013) of NF,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always i need to start from previous three records of dynamic date value. ex: if date value 01-JUN-2013, it considers (01-MAR-2013, 01-APR-2013, 01-MAY-2013) for NF of 01-JUN-2013&lt;/P&gt;&lt;P&gt;Scenario has included in below and also attached.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 622px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" width="42"&gt;PROD&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="38"&gt;CUST&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;REQ_ORD_QTY&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="84"&gt;NF&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="93"&gt;PER_DT&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="301"&gt;NF description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;24&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Apr-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;144&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-May-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;57&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jun-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;123&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;75&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jul-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_APR&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_MAY&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;92&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Aug-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_MAY&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;74.66666667&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Sep-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_AUG&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;80.55555556&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Oct-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_AUG,NF_SEP&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;4&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;82.40740741&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Nov-13&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_AUG,NF_SEP,NF_OCT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;5&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;79.20987654&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Dec-13&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_SEP,NF_OCT,NF_NOV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jan-14&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_OCT,NF_NOV,NF_DEC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl72" height="17" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD class="xl76" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl76" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl77" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;Till 01-Apr-15&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_JAN,NF_FEB,NF_MAR&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sunil Kumar&#xD;
&#xD;
Included one more example in attached file calc.xls, want to calculate new column E(NF) and Column F is pointing calculation of column E in output tab from input data(tab: input).&#xD;
&#xD;
want to generate number of records in output (tab: output)will be dynamamic passed date(01JUL2013) + 20 months records from 01JUL2013 + previous three records from 01JUL2013&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Sep 2013 14:28:46 GMT</pubDate>
    <dc:creator>sunilreddy</dc:creator>
    <dc:date>2013-09-17T14:28:46Z</dc:date>
    <item>
      <title>base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85003#M18286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a numeric column REQ_ORD and need to calculate "NF" column on group variables PROD, CUST, PER_DT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In below example, need to pass dynamic date value '01-JUL-2013' for PER_DT column. need to consider previous 3 records(01-APR-2013, 01-MAY-2013, 01-JUN-2013) from dynamic date value('01-JUL-2013')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mentioned New calculated column "NF"&amp;nbsp; with calculation description(NF description). To calculate NF for 01-Jul-2013, Avg of previous 3 records (01-APR-2013,01-MAY-2013, 01-JUN-2013) of REQ_ORD, To calculate NF for 01-Aug-2013, Avg of first 2 records(01-MAY-2013, 01-JUN-2013) of REQ_ORD and Third record(01-JUL-2013) of NF, To calculate NF for 01-Sep-2013, Avg of first record(01-Jun-2013) of REQ_ORD and last two records (01-JUL-2013, 01-AUG-2013) of NF,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always i need to start from previous three records of dynamic date value. ex: if date value 01-JUN-2013, it considers (01-MAR-2013, 01-APR-2013, 01-MAY-2013) for NF of 01-JUN-2013&lt;/P&gt;&lt;P&gt;Scenario has included in below and also attached.&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 622px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl68" height="20" width="42"&gt;PROD&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="38"&gt;CUST&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="64"&gt;REQ_ORD_QTY&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="84"&gt;NF&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="93"&gt;PER_DT&lt;/TD&gt;&lt;TD class="xl68" style="border-left-color: currentColor; border-left-width: medium; border-left-style: none;" width="301"&gt;NF description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;24&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Apr-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;144&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-May-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl73" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;57&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jun-13&lt;/TD&gt;&lt;TD class="xl73" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl69" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;123&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;75&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jul-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_APR&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_MAY&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;0&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;92&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Aug-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_MAY&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;74.66666667&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Sep-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font6"&gt;REQ_ORD_JUN&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;,&lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_AUG&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;80.55555556&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Oct-13&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;SPAN class="font7"&gt;NF_JUL&lt;/SPAN&gt;&lt;SPAN class="font5"&gt;, &lt;/SPAN&gt;&lt;SPAN class="font7"&gt;NF_AUG,NF_SEP&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;4&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;82.40740741&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Nov-13&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_AUG,NF_SEP,NF_OCT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;5&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;79.20987654&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Dec-13&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_SEP,NF_OCT,NF_NOV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD align="right" class="xl70" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;01-Jan-14&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_OCT,NF_NOV,NF_DEC&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl69" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl69" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl72" height="17" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl72" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl71" height="20" style="border-top-color: currentColor; border-top-width: medium; border-top-style: none;"&gt;130&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;1214&lt;/TD&gt;&lt;TD class="xl76" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl76" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;&lt;/TD&gt;&lt;TD class="xl77" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;Till 01-Apr-15&lt;/TD&gt;&lt;TD class="xl71" style="border-top-color: currentColor; border-left-color: currentColor; border-top-width: medium; border-left-width: medium; border-top-style: none; border-left-style: none;"&gt;NF_JAN,NF_FEB,NF_MAR&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sunil Kumar&#xD;
&#xD;
Included one more example in attached file calc.xls, want to calculate new column E(NF) and Column F is pointing calculation of column E in output tab from input data(tab: input).&#xD;
&#xD;
want to generate number of records in output (tab: output)will be dynamamic passed date(01JUL2013) + 20 months records from 01JUL2013 + previous three records from 01JUL2013&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Sep 2013 14:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85003#M18286</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2013-09-17T14:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85004#M18287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't quite understand your desired logic...but you can join the table to itself with appropriate date criteria to get all of the values on one row...then do the math.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.prod,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.cust,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.req_ord_qty,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.req_ord_qty as req_ord_qty_2,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t3.req_ord_qty as req_ord_qtr_3&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;from &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; have t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t2.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t2.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-1,'begin')=t2.per_dt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t3.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t3.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-2,'begin')=t3.per_dt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t4.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t4.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-3,'begin')=t4.per_dt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t5.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t5.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-4,'begin')=t5.per_dt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t6.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t6.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-5,'begin')=t6.per_dt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join have t7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on t1.prod=t7.prod&lt;/P&gt;&lt;P&gt;&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; and t1.cust=t7.cust&lt;/P&gt;&lt;P&gt;&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; and intnx('month',t1.per_dt,-6,'begin')=t7.per_dt&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Sep 2013 18:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85004#M18287</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2013-09-17T18:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85005#M18288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any updaes on below&lt;/P&gt;&lt;P&gt;Included one more example in attached file calc.xls, want to calculate new column E(NF) and Column F is pointing calculation of column E in output tab from input data(tab: input). want to generate number of records in output (tab: output)will be dynamamic passed date(01JUL2013) + 20 months records from 01JUL2013 + previous three records from 01JUL2013&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 07:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85005#M18288</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2013-09-19T07:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85006#M18289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not tested and will need a bit of tweaking for cases with missing months ( reset counter). Is this what you are after?&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;by prod cust per_dt;&lt;/P&gt;&lt;P&gt;if first.cust then count=0;&lt;/P&gt;&lt;P&gt;count+1;&lt;/P&gt;&lt;P&gt;nf=sum(lag(req_ord_qty),lag2(..),lag3(...))/3;&lt;/P&gt;&lt;P&gt;if count&amp;lt;3 then call missing(NF);&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 07:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85006#M18289</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-09-19T07:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85007#M18290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response. I am looking almost similar to what you are&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried, but not getting expected output.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data out1;&lt;/P&gt;&lt;P&gt; input PROD $ CUST $ REQ_ORD FORE DATE9.;&lt;/P&gt;&lt;P&gt; FORMAT FORE DATE9.;&lt;/P&gt;&lt;P&gt; DATALINES4;&lt;/P&gt;&lt;P&gt; 130 1214 24 01APR2013&lt;BR /&gt; 130 1214 144 01MAY2013&lt;BR /&gt; 130 1214 57 01JUN2013&lt;BR /&gt; 130 1214 123 01JUL2013&lt;BR /&gt; 130 1214 0 01AUG2013&lt;BR /&gt; 130 1214 2 01SEP2013&lt;BR /&gt; 130 1214 3 01OCT2013&lt;BR /&gt; 130 1214 3 01NOV2013&lt;BR /&gt; 130 1214 3 01DEC2013&lt;BR /&gt; 130 1214 3 01JAN2014&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;data OUT2;&lt;BR /&gt;set OUT1;&lt;BR /&gt;by PROD&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CUST&lt;BR /&gt;&amp;nbsp;&amp;nbsp; FORE;&lt;/P&gt;&lt;P&gt;if first.cust then do;&lt;BR /&gt;count=0;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;count +1;&lt;/P&gt;&lt;P&gt;lag1=lag1(REQ_ORD);&lt;BR /&gt;if count le 1 then lag1=.;&lt;/P&gt;&lt;P&gt;lag2=lag2(REQ_ORD);&lt;BR /&gt;if count le 2 then lag2=.;&lt;/P&gt;&lt;P&gt;lag3=lag3(REQ_ORD);&lt;BR /&gt;if count le 3 then lag3=.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NF_QTY=sum(lag1, lag2, lag3)/3;&lt;BR /&gt;if count le 3 then NF_QTY=.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;i need output would be&amp;nbsp; in attached image&lt;IMG alt="NF Calc.jpg" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/4200_NF Calc.jpg" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 09:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85007#M18290</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2013-09-19T09:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85008#M18291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i seem to remember this from somewhere else.....&lt;/P&gt;&lt;P&gt;A rolling N-row average of the incoming data&amp;nbsp; should be easy but care is needed to exclude the current value. Here is how i remember it&lt;/P&gt;&lt;P&gt;%let periods = 3 ; * or longer when wanted;&lt;/P&gt;&lt;P&gt;%let forecast_periods = 20 ;&lt;/P&gt;&lt;P&gt;DATA rolling ;&lt;/P&gt;&lt;P&gt;ARRAY rolls(&amp;amp;periods) _temporary_ ;&lt;/P&gt;&lt;P&gt;NFe = MEAN( OF rolls(*) ) ;&lt;/P&gt;&lt;P&gt;* now insert latest data into rolls array until end of data;&lt;/P&gt;&lt;P&gt;SET&amp;nbsp; original_data end= lastdatarow;&lt;/P&gt;&lt;P&gt;Row+1:&lt;/P&gt;&lt;P&gt;Pointer = MOD( Row, &amp;amp;periods ) +1 ;&lt;/P&gt;&lt;P&gt;rolls( Pointer ) = nf ;&lt;/P&gt;&lt;P&gt;*release data row and finish, unless end of input ;&lt;/P&gt;&lt;P&gt;Output ;&lt;/P&gt;&lt;P&gt;If not lastdatarow then return ;&lt;/P&gt;&lt;P&gt;Do _n_ = rows to ( rows + &amp;amp;forecast_periods ) ;&lt;/P&gt;&lt;P&gt;NFe = MEAN( OF rolls(*) ) ;&lt;/P&gt;&lt;P&gt;Output;&lt;/P&gt;&lt;P&gt;per_dt = intnx( 'month', per_dt, 1 ) ;&lt;/P&gt;&lt;P&gt;Pointer = MOD( _n_, &amp;amp;periods ) +1 ;&lt;/P&gt;&lt;P&gt;Rolls(_n_) = NFe ;&lt;/P&gt;&lt;P&gt;End ;&lt;/P&gt;&lt;P&gt;STOP ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;beware this code is untested&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;peterC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 16:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85008#M18291</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-09-19T16:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: base sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85009#M18292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tested your code as below but still not giving expected&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data out1;&lt;/P&gt;&lt;P&gt; input PROD $ CUST $ NF PER_DT DATE9.;&lt;/P&gt;&lt;P&gt; FORMAT PER_DT DATE9.;&lt;/P&gt;&lt;P&gt; DATALINES4;&lt;/P&gt;&lt;P&gt; 130 1214 24 01APR2013&lt;BR /&gt; 130 1214 144 01MAY2013&lt;BR /&gt; 130 1214 57 01JUN2013&lt;BR /&gt; 130 1214 123 01JUL2013&lt;BR /&gt; 130 1214 0 01AUG2013&lt;BR /&gt; 130 1214 2 01SEP2013&lt;BR /&gt; 130 1214 3 01OCT2013&lt;BR /&gt; 130 1214 3 01NOV2013&lt;BR /&gt; 130 1214 3 01DEC2013&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let periods = 3 ; * or longer when wanted;&lt;/P&gt;&lt;P&gt;%let forecast_periods = 10 ;&lt;/P&gt;&lt;P&gt;DATA rolling ;&lt;/P&gt;&lt;P&gt;ARRAY rolls(&amp;amp;periods) _temporary_ ;&lt;/P&gt;&lt;P&gt;NFe = MEAN( OF rolls(*) ) ;&lt;/P&gt;&lt;P&gt;* now insert latest data into rolls array until end of data;&lt;/P&gt;&lt;P&gt;SET&amp;nbsp; out1 end= lastdatarow;&lt;/P&gt;&lt;P&gt;Row+1;&lt;/P&gt;&lt;P&gt;Pointer = MOD( Row, &amp;amp;periods ) +1 ;&lt;/P&gt;&lt;P&gt;rolls( Pointer ) = nf ;&lt;/P&gt;&lt;P&gt;*release data row and finish, unless end of input ;&lt;/P&gt;&lt;P&gt;Output ;&lt;/P&gt;&lt;P&gt;If not lastdatarow then return ;&lt;/P&gt;&lt;P&gt;Do _n_ = row to ( row + &amp;amp;forecast_periods ) ;&lt;/P&gt;&lt;P&gt;NFe = MEAN( OF rolls(*) ) ;&lt;/P&gt;&lt;P&gt;Output;&lt;/P&gt;&lt;P&gt;per_dt = intnx( 'month', per_dt, 1 ) ;&lt;/P&gt;&lt;P&gt;Pointer = MOD( _n_, &amp;amp;periods ) +1 ;&lt;/P&gt;&lt;P&gt;Rolls(pointer) = NFe ;&lt;/P&gt;&lt;P&gt;End ;&lt;/P&gt;&lt;P&gt;STOP ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2013 20:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/base-sas/m-p/85009#M18292</guid>
      <dc:creator>sunilreddy</dc:creator>
      <dc:date>2013-09-19T20:22:44Z</dc:date>
    </item>
  </channel>
</rss>

