<?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: update data in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599739#M173188</link>
    <description>&lt;P&gt;Use a retained variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lin;
input x;
datalines;
1
2
3
4
.
.
.
;

data want;
set lin;
retain _x 0;
if x = . then x = _x;
_x + x;
drop _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Oct 2019 09:02:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-10-28T09:02:25Z</dc:date>
    <item>
      <title>update data in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599734#M173184</link>
      <description>&lt;P&gt;DEAR ALL:&lt;/P&gt;&lt;P&gt;HERE ,I have a dataset:&lt;/P&gt;&lt;P&gt;data lin;&lt;BR /&gt;input x;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;the &amp;nbsp;missing value should be updated &amp;nbsp;like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;the 5th obs=(1+2+3+4)=10&lt;/P&gt;&lt;P&gt;the 6th obs=1+2+3+4+The5thObs=(1+2+3+4+10)=20;&lt;/P&gt;&lt;P&gt;the 7th obs=1+2+3+4+The5thObs+The6thObs=(1+2+3+4+10+20)=40;&lt;/P&gt;&lt;P&gt;........&lt;/P&gt;&lt;P&gt;the expected result is a sequence like a sequence&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;10&lt;BR /&gt;20&lt;BR /&gt;40&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 08:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599734#M173184</guid>
      <dc:creator>duanzongran</dc:creator>
      <dc:date>2019-10-28T08:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: update data in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599737#M173186</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(keep=x);
    set lin;
    s+x;
    if x=. then do;
        x=s;
        s+x;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;x
1
2
3
4
10
20
40&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 09:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599737#M173186</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-28T09:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: update data in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599739#M173188</link>
      <description>&lt;P&gt;Use a retained variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lin;
input x;
datalines;
1
2
3
4
.
.
.
;

data want;
set lin;
retain _x 0;
if x = . then x = _x;
_x + x;
drop _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Oct 2019 09:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/update-data-in-data-step/m-p/599739#M173188</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-28T09:02:25Z</dc:date>
    </item>
  </channel>
</rss>

