<?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 output previous row in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597950#M16222</link>
    <description>&lt;P&gt;This is the sample code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a_k resid;&lt;BR /&gt;set akkk;&lt;BR /&gt;if mad_command ne 0 then do; output resid and ....; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what I am trying to do is that if mad_command ne 0, then ouput the whole row to resid table AND ALSO OUTPUT the previous row to resid table as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Sun, 20 Oct 2019 01:19:11 GMT</pubDate>
    <dc:creator>eduard1231</dc:creator>
    <dc:date>2019-10-20T01:19:11Z</dc:date>
    <item>
      <title>output previous row</title>
      <link>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597950#M16222</link>
      <description>&lt;P&gt;This is the sample code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a_k resid;&lt;BR /&gt;set akkk;&lt;BR /&gt;if mad_command ne 0 then do; output resid and ....; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what I am trying to do is that if mad_command ne 0, then ouput the whole row to resid table AND ALSO OUTPUT the previous row to resid table as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 20 Oct 2019 01:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597950#M16222</guid>
      <dc:creator>eduard1231</dc:creator>
      <dc:date>2019-10-20T01:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: output previous row</title>
      <link>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597954#M16223</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286929"&gt;@eduard1231&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you asking for this kinda logic?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input var ;
cards;
0
0
4
1
2
;


data want;
set have;
if var ne 0 then do;
output;
n=_n_-1;
set have point=n;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Oct 2019 01:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597954#M16223</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-20T01:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: output previous row</title>
      <link>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597955#M16224</link>
      <description>&lt;P&gt;This is where using the POINT= option of the SET statement helps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a_k resid;
  set akkk;
  output a_k;

  if mad_command ne 0 then do; 
    output resid;
    p=_n_-1;
    set akkk point=p;
    output resid;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program outputs every akkk record to dataset a_k.&amp;nbsp; If outputs the selected record, and its predecessor to resid.&amp;nbsp; Note the original preceding record now follows the precipitating record.&amp;nbsp; If instead you want to preserve the original order, you can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a_k resid;
  set akkk;
  output a_k;

  if mad_command ne 0 then do p=_n_-1 to _n_;
    set akkk point=p;
    output resid;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Oct 2019 01:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/output-previous-row/m-p/597955#M16224</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-20T01:49:10Z</dc:date>
    </item>
  </channel>
</rss>

