<?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 keep the observations till value is 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820675#M323957</link>
    <description>&lt;P&gt;I have my data like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data abc;&lt;BR /&gt;input alt_acc$ acc x;&lt;BR /&gt;datalines;&lt;BR /&gt;2123 001 1&lt;BR /&gt;2234 001 0&lt;BR /&gt;2345 001 0&lt;BR /&gt;Y123 002 4&lt;BR /&gt;Y345 002 7&lt;BR /&gt;Y513 002 0&lt;BR /&gt;Z123 002 6&lt;BR /&gt;L123 003 0&lt;BR /&gt;L234 003 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want output like below:&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;alt_acc Acc x&lt;/P&gt;&lt;P&gt;2123 001 1&lt;BR /&gt;2234 001 0&lt;BR /&gt;Y123 002 4&lt;BR /&gt;Y345 002 7&lt;BR /&gt;Y513 002 0&lt;BR /&gt;L123 003 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the records till my x value is zero for all accounts(acc).&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2022 12:27:31 GMT</pubDate>
    <dc:creator>Srinivas1516</dc:creator>
    <dc:date>2022-06-28T12:27:31Z</dc:date>
    <item>
      <title>keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820675#M323957</link>
      <description>&lt;P&gt;I have my data like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data abc;&lt;BR /&gt;input alt_acc$ acc x;&lt;BR /&gt;datalines;&lt;BR /&gt;2123 001 1&lt;BR /&gt;2234 001 0&lt;BR /&gt;2345 001 0&lt;BR /&gt;Y123 002 4&lt;BR /&gt;Y345 002 7&lt;BR /&gt;Y513 002 0&lt;BR /&gt;Z123 002 6&lt;BR /&gt;L123 003 0&lt;BR /&gt;L234 003 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want output like below:&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;alt_acc Acc x&lt;/P&gt;&lt;P&gt;2123 001 1&lt;BR /&gt;2234 001 0&lt;BR /&gt;Y123 002 4&lt;BR /&gt;Y345 002 7&lt;BR /&gt;Y513 002 0&lt;BR /&gt;L123 003 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the records till my x value is zero for all accounts(acc).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820675#M323957</guid>
      <dc:creator>Srinivas1516</dc:creator>
      <dc:date>2022-06-28T12:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820679#M323958</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data abc;
input alt_acc$ acc x;
datalines;
2123 001 1
2234 001 0
2345 001 0
Y123 002 4
Y345 002 7
Y513 002 0
Z123 002 6
L123 003 0
L234 003 1
;
run;
data want;
	set abc;
	by acc;
	retain _x;
	if first.acc then _x =.;
	if _x = . ;
	if x=0  then _x=x;
	drop _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820679#M323958</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2022-06-28T12:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820682#M323960</link>
      <description>&lt;PRE&gt;data abc;
input alt_acc$ acc x;
datalines;
2123 001 1
2234 001 0
2345 001 0
Y123 002 4
Y345 002 7
Y513 002 0
Z123 002 6
L123 003 0
L234 003 1
;
run;

data want;
 set abc;
 by acc;
 retain is_zero;
 if first.acc then is_zero=0;
 if is_zero=0;
 if x=0 then is_zero=1;
drop is_zero;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820682#M323960</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-06-28T12:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820683#M323961</link>
      <description>&lt;P&gt;If zero occurs in X variable for an account, we need before record also for that account in the output&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820683#M323961</guid>
      <dc:creator>Srinivas1516</dc:creator>
      <dc:date>2022-06-28T12:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820685#M323962</link>
      <description>&lt;P&gt;Looks like a case for the do until loop!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
    do until(last.acc);
        set abc;
        by acc;

        if not zerofound then
            output;

        if x=0 then
            zerofound=1;
    end;
    drop zerofound;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 13:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820685#M323962</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-28T13:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820686#M323963</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Y123 002 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Y345 002 7&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Above are not capturing&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 13:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820686#M323963</guid>
      <dc:creator>Srinivas1516</dc:creator>
      <dc:date>2022-06-28T13:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: keep the observations till value is 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820688#M323964</link>
      <description>&lt;P&gt;yes they are. Do proc print of want2 dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tarheel13_0-1656422617350.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72775i600EA118054BBA0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tarheel13_0-1656422617350.png" alt="tarheel13_0-1656422617350.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 13:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-the-observations-till-value-is-0/m-p/820688#M323964</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-28T13:23:49Z</dc:date>
    </item>
  </channel>
</rss>

