<?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 repeating past output in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528120#M5350</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;for current month i want the output to equal num_0 but for future months i want it to equal to past months Num_1.&lt;BR /&gt;&lt;BR /&gt;data have;
input id num_0  date:date9. num_1 ;
format date date9.;
datalines; 
1 20 06JAN2019 50  
1 20 13JAN2019 50
1  20 20JAN2019 50 
1  20 27JAN2019 50
1 20 03FEB2019  100
1 20 10FEB2019 100
1  20 17FEB2019  100
1 20  24FEB2019  100
1 20 03MAR2019  150&lt;BR /&gt;1 20 10MAR2019 150&lt;BR /&gt;1 20 17MAR2019 150 &lt;BR /&gt;1 20 24MAR2019 150&lt;BR /&gt;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;output i want :&amp;nbsp;&lt;/P&gt;&lt;P&gt;id num_0 date num_1 num_2&lt;BR /&gt;1 20 06JAN2019 50 20&lt;BR /&gt;1 20 13JAN2019 50 20&lt;BR /&gt;1 20 20JAN2019 50 20&lt;BR /&gt;1 20 27JAN2019 50 20&lt;BR /&gt;1 20 03FEB2019 100 50&lt;BR /&gt;1 20 10FEB2019 100 50&lt;BR /&gt;1 20 17FEB2019 100 50&lt;BR /&gt;1 20 24FEB2019 100 50&lt;BR /&gt;1 20 03MAR2019 150 100&lt;BR /&gt;1 20 10MAR2019 150 100&lt;BR /&gt;1 20 17MAR2019 150 100&lt;BR /&gt;1 20 24MAR2019 150 100&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jan 2019 19:10:37 GMT</pubDate>
    <dc:creator>hk2013</dc:creator>
    <dc:date>2019-01-17T19:10:37Z</dc:date>
    <item>
      <title>repeating past output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528120#M5350</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;for current month i want the output to equal num_0 but for future months i want it to equal to past months Num_1.&lt;BR /&gt;&lt;BR /&gt;data have;
input id num_0  date:date9. num_1 ;
format date date9.;
datalines; 
1 20 06JAN2019 50  
1 20 13JAN2019 50
1  20 20JAN2019 50 
1  20 27JAN2019 50
1 20 03FEB2019  100
1 20 10FEB2019 100
1  20 17FEB2019  100
1 20  24FEB2019  100
1 20 03MAR2019  150&lt;BR /&gt;1 20 10MAR2019 150&lt;BR /&gt;1 20 17MAR2019 150 &lt;BR /&gt;1 20 24MAR2019 150&lt;BR /&gt;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;output i want :&amp;nbsp;&lt;/P&gt;&lt;P&gt;id num_0 date num_1 num_2&lt;BR /&gt;1 20 06JAN2019 50 20&lt;BR /&gt;1 20 13JAN2019 50 20&lt;BR /&gt;1 20 20JAN2019 50 20&lt;BR /&gt;1 20 27JAN2019 50 20&lt;BR /&gt;1 20 03FEB2019 100 50&lt;BR /&gt;1 20 10FEB2019 100 50&lt;BR /&gt;1 20 17FEB2019 100 50&lt;BR /&gt;1 20 24FEB2019 100 50&lt;BR /&gt;1 20 03MAR2019 150 100&lt;BR /&gt;1 20 10MAR2019 150 100&lt;BR /&gt;1 20 17MAR2019 150 100&lt;BR /&gt;1 20 24MAR2019 150 100&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2019 19:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528120#M5350</guid>
      <dc:creator>hk2013</dc:creator>
      <dc:date>2019-01-17T19:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: repeating past output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528137#M5358</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id num_0  date :date9. num_1 ;
format date date9.;
datalines; 
1 20 06JAN2019 50  
1 20 13JAN2019 50
1  20 20JAN2019 50 
1  20 27JAN2019 50
1 20 03FEB2019  100
1 20 10FEB2019 100
1  20 17FEB2019  100
1 20  24FEB2019  100
1 20 03MAR2019  150
1 20 10MAR2019 150
1 20 17MAR2019 150
1 20 24MAR2019 150
;
data temp;
set have;
by id date ;
t=put(date,monyy.);/*assigning month year for by group creation*/
run;
data want;
set temp;
by id  t notsorted;
retain k num_2;
if _n_=1 then k=put(today(),monyy.) ;/*getting the current month*/
if first.t then  num_2=lag(num_1);
if k=t then num_2=num_0;
drop t k;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 19:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528137#M5358</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-17T19:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: repeating past output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528253#M5382</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id num_0  date :date9. num_1 ;
format date date9.;
datalines; 
1 20 06JAN2019 50  
1 20 13JAN2019 50
1  20 20JAN2019 50 
1  20 27JAN2019 50
1 20 03FEB2019  100
1 20 10FEB2019 100
1  20 17FEB2019  100
1 20  24FEB2019  100
1 20 03MAR2019  150
1 20 10MAR2019 150
1 20 17MAR2019 150
1 20 24MAR2019 150
;
data have;
set have;
_date=intnx('month',date,0);
format _date date9.;
run;
data temp;
set have;
_date=intnx('month',date,1);
format _date date9.;
run;
data want;
merge have(in=ina) temp(keep=id _date num_1 rename=(num_1=_num_1));
by id _date;
if year(today())=year(date) and month(today())=month(date) then  num_2= num_0;
 else  num_2= _num_1;
if ina;
drop _: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Jan 2019 06:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/repeating-past-output/m-p/528253#M5382</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-01-18T06:41:26Z</dc:date>
    </item>
  </channel>
</rss>

