<?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: Filter dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11429#M1358</link>
    <description>data temp;&lt;BR /&gt;
input a $ b ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A 840&lt;BR /&gt;
A 841&lt;BR /&gt;
A 842&lt;BR /&gt;
A 843&lt;BR /&gt;
A 844&lt;BR /&gt;
A 845&lt;BR /&gt;
B 840&lt;BR /&gt;
B 841&lt;BR /&gt;
B 842&lt;BR /&gt;
C 840&lt;BR /&gt;
C 841&lt;BR /&gt;
C 842&lt;BR /&gt;
C 843&lt;BR /&gt;
C 844&lt;BR /&gt;
C 845&lt;BR /&gt;
D 842&lt;BR /&gt;
D 843&lt;BR /&gt;
D 844&lt;BR /&gt;
D 845&lt;BR /&gt;
;run;&lt;BR /&gt;
&lt;BR /&gt;
data temp2(keep=a);&lt;BR /&gt;
set temp;&lt;BR /&gt;
by a;&lt;BR /&gt;
if first.a then counter =1;&lt;BR /&gt;
else counter +1;&lt;BR /&gt;
if counter=6 then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
i am checking if a stock has 6 records  if it is so then i am taking that stock to output.. not sure if this is what u wanted.</description>
    <pubDate>Tue, 14 Jun 2011 04:44:05 GMT</pubDate>
    <dc:creator>Rockers</dc:creator>
    <dc:date>2011-06-14T04:44:05Z</dc:date>
    <item>
      <title>Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11424#M1353</link>
      <description>Dear Sas users,&lt;BR /&gt;
&lt;BR /&gt;
I have difficulties filtering a dataset;&lt;BR /&gt;
&lt;BR /&gt;
I only want these observations that have no missing values between day 840 and 845.&lt;BR /&gt;
&lt;BR /&gt;
For example,&lt;BR /&gt;
&lt;BR /&gt;
STOCK     DATE&lt;BR /&gt;
&lt;BR /&gt;
A	840&lt;BR /&gt;
A	841&lt;BR /&gt;
A	842&lt;BR /&gt;
A	843&lt;BR /&gt;
A	844&lt;BR /&gt;
A	845&lt;BR /&gt;
B	840&lt;BR /&gt;
B	841&lt;BR /&gt;
B	842&lt;BR /&gt;
C	840&lt;BR /&gt;
C	841&lt;BR /&gt;
C	842&lt;BR /&gt;
C	843&lt;BR /&gt;
C	844&lt;BR /&gt;
C	845&lt;BR /&gt;
D	842&lt;BR /&gt;
D	843&lt;BR /&gt;
D	844&lt;BR /&gt;
D	845&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I can only take these stocks that have non missing values between 840 and 845.&lt;BR /&gt;
So I Cannot select stock C and B. Ans I want a new dataset only with the variables A and D.&lt;BR /&gt;
How do I use a proper filter technique?&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
&lt;BR /&gt;
Stefaan&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: OzoneX15

Message was edited by: OzoneX15</description>
      <pubDate>Sat, 11 Jun 2011 11:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11424#M1353</guid>
      <dc:creator>OzoneX15</dc:creator>
      <dc:date>2011-06-11T11:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11425#M1354</link>
      <description>I thought to &lt;BR /&gt;
&lt;BR /&gt;
1) use the filter between 840 and 845&lt;BR /&gt;
2) Count by stock&lt;BR /&gt;
3) filter only those who have a count five&lt;BR /&gt;
&lt;BR /&gt;
but this is not the right way I suppose?</description>
      <pubDate>Sat, 11 Jun 2011 12:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11425#M1354</guid>
      <dc:creator>OzoneX15</dc:creator>
      <dc:date>2011-06-11T12:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11426#M1355</link>
      <description>Hi.&lt;BR /&gt;
Be honest. I cannot understand what is your logic exactly.&lt;BR /&gt;
You said So I Cannot select stock C and B. Why? It is because they are all started with date=840 ? Supposing it were.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input STOCK $ DATE ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A 840&lt;BR /&gt;
A 841&lt;BR /&gt;
A 842&lt;BR /&gt;
A 843&lt;BR /&gt;
A 844&lt;BR /&gt;
A 845&lt;BR /&gt;
B 840&lt;BR /&gt;
B 841&lt;BR /&gt;
B 842&lt;BR /&gt;
C 840&lt;BR /&gt;
C 841&lt;BR /&gt;
C 842&lt;BR /&gt;
C 843&lt;BR /&gt;
C 844&lt;BR /&gt;
C 845&lt;BR /&gt;
D 842&lt;BR /&gt;
D 843&lt;BR /&gt;
D 844&lt;BR /&gt;
D 845&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp(where =(count eq 1));&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 if stock ne lag(stock) then do;&lt;BR /&gt;
                               if date=840 then count+1;&lt;BR /&gt;
                                else count=1;&lt;BR /&gt;
                              end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 13 Jun 2011 03:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11426#M1355</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-13T03:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11427#M1356</link>
      <description>One way (sort of hard-coded):&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create able stocks as&lt;BR /&gt;
select t0.stock&lt;BR /&gt;
from&lt;BR /&gt;
(select * from stocks where date=840) t0&lt;BR /&gt;
inner join (select * from stocks where date=841) t1 on t0.stock=t1.stock&lt;BR /&gt;
inner join (select * from stocks where date=842) t2 on t0.stock=t2.stock&lt;BR /&gt;
inner join (select * from stocks where date=843) t3 on t0.stock=t3.stock&lt;BR /&gt;
inner join (select * from stocks where date=844) t4 on t0.stock=t4.stock&lt;BR /&gt;
inner join (select * from stocks where date=845) t5 on t0.stock=t5.stock;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
That's not an optimal solution as it might not be easily adapted to other questions..but it should work.</description>
      <pubDate>Mon, 13 Jun 2011 11:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11427#M1356</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-06-13T11:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11428#M1357</link>
      <description>Thanks,&lt;BR /&gt;
&lt;BR /&gt;
It works now.&lt;BR /&gt;
I thought Sas would have a specific filter for this.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
&lt;BR /&gt;
Stefaan</description>
      <pubDate>Mon, 13 Jun 2011 21:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11428#M1357</guid>
      <dc:creator>OzoneX15</dc:creator>
      <dc:date>2011-06-13T21:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Filter dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11429#M1358</link>
      <description>data temp;&lt;BR /&gt;
input a $ b ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A 840&lt;BR /&gt;
A 841&lt;BR /&gt;
A 842&lt;BR /&gt;
A 843&lt;BR /&gt;
A 844&lt;BR /&gt;
A 845&lt;BR /&gt;
B 840&lt;BR /&gt;
B 841&lt;BR /&gt;
B 842&lt;BR /&gt;
C 840&lt;BR /&gt;
C 841&lt;BR /&gt;
C 842&lt;BR /&gt;
C 843&lt;BR /&gt;
C 844&lt;BR /&gt;
C 845&lt;BR /&gt;
D 842&lt;BR /&gt;
D 843&lt;BR /&gt;
D 844&lt;BR /&gt;
D 845&lt;BR /&gt;
;run;&lt;BR /&gt;
&lt;BR /&gt;
data temp2(keep=a);&lt;BR /&gt;
set temp;&lt;BR /&gt;
by a;&lt;BR /&gt;
if first.a then counter =1;&lt;BR /&gt;
else counter +1;&lt;BR /&gt;
if counter=6 then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
i am checking if a stock has 6 records  if it is so then i am taking that stock to output.. not sure if this is what u wanted.</description>
      <pubDate>Tue, 14 Jun 2011 04:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Filter-dataset/m-p/11429#M1358</guid>
      <dc:creator>Rockers</dc:creator>
      <dc:date>2011-06-14T04:44:05Z</dc:date>
    </item>
  </channel>
</rss>

