<?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: Deleting some obs conditionally of the previous obs. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560244#M156616</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

DATA HAVE;
infile cards truncover;
INPUT COLUMN $200.;
DATALINES;
AAAA
BBBB
/BBBB
CCCC
DDDD
EEEE
/EEEE
FFFF
/FFFF
GGGG
;
RUN;

data want;
merge have have(firstobs=2 rename=COLUMN=C);
COLUMN=compress(COLUMN,'/');
C=compress(c,'/');
if column=c or lag(COLUMN)=COLUMN then delete;
drop c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 May 2019 18:20:28 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-05-20T18:20:28Z</dc:date>
    <item>
      <title>Deleting some obs conditionally of the previous obs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560238#M156611</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that consist of a column, 2 consecutive obs can have the same value just the second has a '/'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;DATA HAVE;
INPUT COLUMN $200;
DATALINES;
AAAA
BBBB
/BBBB
CCCC
DDDD
EEEE
/EEEE
FFFF
/FFFF
GGGG
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to build a program that check if 2 consecutive rows have the same value and delete both.&lt;/P&gt;&lt;P&gt;To have :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
INPUT COLUMN $200;
DATALINES;
AAAA
CCCC
DDDD
GGGG
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do you have any idea how to do that ?&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 17:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560238#M156611</guid>
      <dc:creator>Hugo_B</dc:creator>
      <dc:date>2019-05-20T17:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting some obs conditionally of the previous obs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560241#M156613</link>
      <description>&lt;P&gt;I like the BY statement with first-DOT and last-DOT's. This doesn't delete records, but instead just doesn't output them if the values aren't unique. You can see where I remove the "/" character in the second dataset. This also assumes that the original data is sorted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA HAVE;
length column $200;
INPUT COLUMN;
DATALINES;
AAAA
BBBB
/BBBB
CCCC
DDDD
EEEE
/EEEE
FFFF
/FFFF
GGGG
;;;;;
RUN;
data temp;
	set have;
	if substr(column,1,1)="/" then column=substr(column,2, 200);
run;
data want;
	set temp;
	by column;
	if first.column and last.column;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 18:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560241#M156613</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-05-20T18:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting some obs conditionally of the previous obs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560244#M156616</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

DATA HAVE;
infile cards truncover;
INPUT COLUMN $200.;
DATALINES;
AAAA
BBBB
/BBBB
CCCC
DDDD
EEEE
/EEEE
FFFF
/FFFF
GGGG
;
RUN;

data want;
merge have have(firstobs=2 rename=COLUMN=C);
COLUMN=compress(COLUMN,'/');
C=compress(c,'/');
if column=c or lag(COLUMN)=COLUMN then delete;
drop c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 18:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560244#M156616</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-20T18:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting some obs conditionally of the previous obs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560245#M156617</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA HAVE;
infile cards truncover;
INPUT COLUMN $200.;
DATALINES;
AAAA
BBBB
/BBBB
CCCC
DDDD
EEEE
/EEEE
FFFF
/FFFF
GGGG
;
RUN;

proc sql;
create table want(drop=c) as
select *,compress(COLUMN,'/') as c
from have
group by c
having count(c)=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 May 2019 18:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560245#M156617</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-20T18:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting some obs conditionally of the previous obs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560384#M156689</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  have
  have (rename=(column=_column) firstobs=2)
;
if substr(column,1,1) ne '/' and column ne substr(_column,2);
drop _column;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;column

 AAAA 
 CCCC 
 DDDD 
 GGGG 
&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2019 07:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-some-obs-conditionally-of-the-previous-obs/m-p/560384#M156689</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-21T07:53:12Z</dc:date>
    </item>
  </channel>
</rss>

