<?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: delete the rows for group condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586094#M167276</link>
    <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
flag=lag(events);
if first.id then flag=.;
if flag=1 then delete;
drop flag;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Sep 2019 12:54:37 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2019-09-04T12:54:37Z</dc:date>
    <item>
      <title>delete the rows for group condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586093#M167275</link>
      <description>&lt;P&gt;Dear Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to delete the rows using a condition given below. Kindly go through my sample dataset for better details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id Events value;
cards;
101 0 12
101 0 15
101 1 14
101 0 18
108 0 45
108 1 25
108 0 23
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the given set. I want to delete the row which occurs after the event meets 1.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rows need to delete :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;101 0 18&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;108 0 23&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;Kindly suggest some code to solve the task&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586093#M167275</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-09-04T12:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: delete the rows for group condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586094#M167276</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
flag=lag(events);
if first.id then flag=.;
if flag=1 then delete;
drop flag;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586094#M167276</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-04T12:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: delete the rows for group condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586096#M167278</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Id Events value;
cards;
101 0 12
101 0 15
101 1 14
101 0 18
108 0 45
108 1 25
108 0 23
;

data want;
 do until(last.id);
 set have;
 by id;
 if not n then output;
 if EVENTS then n=1;
 end;
 drop n;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586096#M167278</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-04T12:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: delete the rows for group condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586109#M167283</link>
      <description>&lt;P&gt;Just for fun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id Events value;
cards;
101 0 12
101 0 15
101 1 14
101 0 18
108 0 45
108 1 25
108 0 23
;

data want;
 set have;
 by id;
 retain flag;
 lag=lag(events);
 if first.id then call missing(lag,flag);
 if lag then flag=1;
 if flag then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delete-the-rows-for-group-condition/m-p/586109#M167283</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-04T13:40:47Z</dc:date>
    </item>
  </channel>
</rss>

