<?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 use retain in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776437#M246945</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sell_2;
set sell;
retain _selling _benefit;
if _n_ = 1
then do;
  _selling = selling;
  _benefit = benifit;
end;
else do;
  _selling = _selling * 1.1;
  _benefit = _benefit * 1.05;
  selling = _selling;
  benifit = _benefit;
end;
drop _:;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need additional variables because otherwise the missing values from the dataset variables will override the retained values.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 12:13:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-26T12:13:53Z</dc:date>
    <item>
      <title>HOW to use retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776429#M246941</link>
      <description>&lt;P&gt;There is a dataset, i want to know how to do some calculation with using REATAIN.&lt;/P&gt;&lt;P&gt;New variable p_selling for 2014 to 2017, the predicted selling will be 10% more than the previous year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;New variable p_benifit for 2014 to 2017, the predicted&amp;nbsp;benifit will be 5% more than the previous year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Sell;&lt;BR /&gt;&amp;nbsp; INPUT Year Selling benifit;&lt;BR /&gt;&amp;nbsp; DATALINES;&lt;BR /&gt;2013 50000 3000&lt;BR /&gt;2014 . .&lt;BR /&gt;2015 . .&lt;BR /&gt;2016 . .&lt;BR /&gt;2017 . .&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA Sell_2;&lt;BR /&gt;&amp;nbsp; SET Sell;&lt;BR /&gt;&amp;nbsp; /* ???????????? */&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 11:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776429#M246941</guid>
      <dc:creator>NitcanRicky</dc:creator>
      <dc:date>2021-10-26T11:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: HOW to use retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776437#M246945</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sell_2;
set sell;
retain _selling _benefit;
if _n_ = 1
then do;
  _selling = selling;
  _benefit = benifit;
end;
else do;
  _selling = _selling * 1.1;
  _benefit = _benefit * 1.05;
  selling = _selling;
  benifit = _benefit;
end;
drop _:;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need additional variables because otherwise the missing values from the dataset variables will override the retained values.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 12:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776437#M246945</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-26T12:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: HOW to use retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776438#M246946</link>
      <description>&lt;P&gt;Please see this similar example:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/how-to-use-loop-to-calculate-row-by-row-without-creating-new/m-p/774670#M246235" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/how-to-use-loop-to-calculate-row-by-row-without-creating-new/m-p/774670#M246235&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 12:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/HOW-to-use-retain/m-p/776438#M246946</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-26T12:15:20Z</dc:date>
    </item>
  </channel>
</rss>

