<?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: A question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9189#M572</link>
    <description>Easy.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Type $ PH $ SEQ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A Y 1&lt;BR /&gt;
A N 2&lt;BR /&gt;
A N 3&lt;BR /&gt;
A N 4&lt;BR /&gt;
B Y 2&lt;BR /&gt;
B N 1&lt;BR /&gt;
B N 3&lt;BR /&gt;
B N 5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 by type;&lt;BR /&gt;
 if first.type then count=0;&lt;BR /&gt;
 if ph='Y' then output;&lt;BR /&gt;
  else if ph='N' then count+1;&lt;BR /&gt;
 if count le 2 and ph='N' then output;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Wed, 08 Jun 2011 10:01:12 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-06-08T10:01:12Z</dc:date>
    <item>
      <title>A question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9188#M571</link>
      <description>I have a data with the format as:&lt;BR /&gt;
&lt;BR /&gt;
Type  PH  SEQ&lt;BR /&gt;
A       Y    1&lt;BR /&gt;
A       N    2&lt;BR /&gt;
A       N    3&lt;BR /&gt;
A       N    4&lt;BR /&gt;
B       Y    2&lt;BR /&gt;
B       N    1&lt;BR /&gt;
B       N    3&lt;BR /&gt;
B       N    5&lt;BR /&gt;
&lt;BR /&gt;
The data can be easily sorted based on Type, PH and SEQ as shown above. Now the question is to pick up:&lt;BR /&gt;
1) all the records with PH=Y, and &lt;BR /&gt;
2) the first two records in the sorted data where PH=N.&lt;BR /&gt;
&lt;BR /&gt;
So the results should be like:&lt;BR /&gt;
Type  PH  SEQ&lt;BR /&gt;
A       Y    1&lt;BR /&gt;
A       N    2&lt;BR /&gt;
A       N    3&lt;BR /&gt;
B       Y    2&lt;BR /&gt;
B       N    1&lt;BR /&gt;
B       N    3&lt;BR /&gt;
&lt;BR /&gt;
How can I do that?</description>
      <pubDate>Wed, 08 Jun 2011 09:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9188#M571</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-06-08T09:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: A question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9189#M572</link>
      <description>Easy.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Type $ PH $ SEQ;&lt;BR /&gt;
cards;&lt;BR /&gt;
A Y 1&lt;BR /&gt;
A N 2&lt;BR /&gt;
A N 3&lt;BR /&gt;
A N 4&lt;BR /&gt;
B Y 2&lt;BR /&gt;
B N 1&lt;BR /&gt;
B N 3&lt;BR /&gt;
B N 5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 by type;&lt;BR /&gt;
 if first.type then count=0;&lt;BR /&gt;
 if ph='Y' then output;&lt;BR /&gt;
  else if ph='N' then count+1;&lt;BR /&gt;
 if count le 2 and ph='N' then output;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 08 Jun 2011 10:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9189#M572</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-08T10:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: A question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9190#M573</link>
      <description>Thanks for your help, Ksharp.</description>
      <pubDate>Wed, 08 Jun 2011 10:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/A-question/m-p/9190#M573</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-06-08T10:46:51Z</dc:date>
    </item>
  </channel>
</rss>

