<?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 help with retain statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508845#M136695</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;I created a data set 'two' which is similar to what i am working. I need help in data three. The retain and lag function are not getting the output I need. Please help. Thank you&lt;/P&gt;
&lt;P&gt;I need to populate variable 'a' from previous value if missing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed;&lt;/P&gt;
&lt;P&gt;a 1 &lt;BR /&gt;a 2 &lt;BR /&gt;a 3&lt;BR /&gt;d 4&lt;BR /&gt;d 5&lt;BR /&gt;g 6 &lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a $ b ;
datalines;
a 1 
b 2 
c 3
d 4
e 5
g 6 
;
data two;
set one;
if b in (2,3,5) then a='';
run;&lt;BR /&gt;
data three;
set two;
retain c;
c=lag(a);
if a ='' then a=lag(c);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Oct 2018 17:50:56 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2018-10-30T17:50:56Z</dc:date>
    <item>
      <title>help with retain statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508845#M136695</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;I created a data set 'two' which is similar to what i am working. I need help in data three. The retain and lag function are not getting the output I need. Please help. Thank you&lt;/P&gt;
&lt;P&gt;I need to populate variable 'a' from previous value if missing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed;&lt;/P&gt;
&lt;P&gt;a 1 &lt;BR /&gt;a 2 &lt;BR /&gt;a 3&lt;BR /&gt;d 4&lt;BR /&gt;d 5&lt;BR /&gt;g 6 &lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a $ b ;
datalines;
a 1 
b 2 
c 3
d 4
e 5
g 6 
;
data two;
set one;
if b in (2,3,5) then a='';
run;&lt;BR /&gt;
data three;
set two;
retain c;
c=lag(a);
if a ='' then a=lag(c);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 17:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508845#M136695</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-10-30T17:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: help with retain statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508850#M136696</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set two;
retain _a;
if not missing(a) then _a=a;
else a=_a;
drop _a;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 17:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508850#M136696</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-30T17:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: help with retain statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508852#M136697</link>
      <description>&lt;P&gt;Just assign C when not missing and retain those until the next non-missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data three;
set two;
retain c;
if not missing(a) then c=a;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 18:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-retain-statement/m-p/508852#M136697</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-30T18:00:38Z</dc:date>
    </item>
  </channel>
</rss>

