<?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: Eliminating consecutive values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737057#M28782</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your dataset is grouped by &lt;FONT face="courier new,courier"&gt;ID&lt;/FONT&gt; and sorted by &lt;FONT face="courier new,courier"&gt;Date&lt;/FONT&gt; within each &lt;FONT face="courier new,courier"&gt;ID&lt;/FONT&gt; BY group, you can use a so-called double DOW-loop to eliminate the IDs in question:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Date :mmddyy. test;
format date mmddyy8.;
cards;
R45 3/15/19 90
R45 4/15/19 100
R45 5/15/19 70
R45 6/15/19 60
R90 3/15/19 12
R90 4/15/19 120
R90 5/15/19 45
R90 6/15/19 100
R30 3/15/19 72
R30 4/15/19 28
R30 5/15/19 50
R30 6/15/19 220
;

data want(drop=tbd);
do until(last.id);
  set have;
  by id notsorted;
  if ~first.id &amp;amp; test&amp;gt;80 &amp;amp; lag(test)&amp;gt;80 then tbd=1; /* "to be deleted" */
end;
do until(last.id);
  set have;
  by id notsorted;
  if ~tbd then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Apr 2021 17:19:58 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-04-26T17:19:58Z</dc:date>
    <item>
      <title>Eliminating consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737036#M28781</link>
      <description>&lt;P&gt;From the data below and I am tryign to eliminate those that have two consecutive test above 80. How Do I go about doing My analysis?&amp;nbsp; for example, in the table below, ID R45 will be excluded because it as two test above 80 consecutively&amp;nbsp; (test 90 and test 100). Thanks&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Date&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;90&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;70&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R45&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;60&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;120&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;72&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;28&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;220&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my output would look like this&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;ID&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Date&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;test&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;120&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R90&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;3/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;72&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;4/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;28&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;R30&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;6/15/19&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;220&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 16:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737036#M28781</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2021-04-26T16:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737057#M28782</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222563"&gt;@hjjijkkl&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your dataset is grouped by &lt;FONT face="courier new,courier"&gt;ID&lt;/FONT&gt; and sorted by &lt;FONT face="courier new,courier"&gt;Date&lt;/FONT&gt; within each &lt;FONT face="courier new,courier"&gt;ID&lt;/FONT&gt; BY group, you can use a so-called double DOW-loop to eliminate the IDs in question:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Date :mmddyy. test;
format date mmddyy8.;
cards;
R45 3/15/19 90
R45 4/15/19 100
R45 5/15/19 70
R45 6/15/19 60
R90 3/15/19 12
R90 4/15/19 120
R90 5/15/19 45
R90 6/15/19 100
R30 3/15/19 72
R30 4/15/19 28
R30 5/15/19 50
R30 6/15/19 220
;

data want(drop=tbd);
do until(last.id);
  set have;
  by id notsorted;
  if ~first.id &amp;amp; test&amp;gt;80 &amp;amp; lag(test)&amp;gt;80 then tbd=1; /* "to be deleted" */
end;
do until(last.id);
  set have;
  by id notsorted;
  if ~tbd then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 17:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737057#M28782</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-26T17:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating consecutive values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737254#M28797</link>
      <description>&lt;PRE&gt;data have;
input ID $ Date :mmddyy. test;
format date mmddyy8.;
cards;
R45 3/15/19 90
R45 4/15/19 100
R45 5/15/19 70
R45 6/15/19 60
R90 3/15/19 12
R90 4/15/19 120
R90 5/15/19 45
R90 6/15/19 100
R30 3/15/19 72
R30 4/15/19 28
R30 5/15/19 50
R30 6/15/19 220
;
data temp;
 set have;
 flag=ifn(test&amp;gt;80,1,0);
run;
proc summary data=temp;
by id flag notsorted;
output out=temp1;
run;
proc sql;
create table want as
select * from have where id not in (select id from temp1 where flag=1 and _freq_&amp;gt;1);
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 13:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Eliminating-consecutive-values/m-p/737254#M28797</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-04-27T13:02:56Z</dc:date>
    </item>
  </channel>
</rss>

