<?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: Phyid and Flag in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73674#M15855</link>
    <description>If flag can only have those two values then you could sort by phyid and flag.  Then use by group processing with first.flag and last.flag to exclude observations that are both first and last within a group.</description>
    <pubDate>Tue, 21 Sep 2010 18:43:53 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2010-09-21T18:43:53Z</dc:date>
    <item>
      <title>Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73673#M15854</link>
      <description>The phyid's have flag 'C' or 'P'. How do to display phyid that have flag 'C' and 'P'.&lt;BR /&gt;
&lt;BR /&gt;
for instance:&lt;BR /&gt;
&lt;BR /&gt;
Phyid             flag&lt;BR /&gt;
1001                C&lt;BR /&gt;
1002                P&lt;BR /&gt;
1003                C&lt;BR /&gt;
1003                P&lt;BR /&gt;
1004                C&lt;BR /&gt;
1004                P&lt;BR /&gt;
&lt;BR /&gt;
display only 1003 and 1004 as they have flag 'C' and 'P'.</description>
      <pubDate>Tue, 21 Sep 2010 18:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73673#M15854</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-09-21T18:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73674#M15855</link>
      <description>If flag can only have those two values then you could sort by phyid and flag.  Then use by group processing with first.flag and last.flag to exclude observations that are both first and last within a group.</description>
      <pubDate>Tue, 21 Sep 2010 18:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73674#M15855</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-09-21T18:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73675#M15856</link>
      <description>[pre]&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input phyid flag $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1001 C&lt;BR /&gt;
1002 P&lt;BR /&gt;
1003 C&lt;BR /&gt;
1003 P&lt;BR /&gt;
1004 C&lt;BR /&gt;
1004 P&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	select phyid from test where flag = 'C'&lt;BR /&gt;
	intersect&lt;BR /&gt;
	select phyid from test where flag = 'P';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 21 Sep 2010 19:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73675#M15856</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2010-09-21T19:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73676#M15857</link>
      <description>Thanks.&lt;BR /&gt;
Phyid flag&lt;BR /&gt;
1001 C&lt;BR /&gt;
1002 P&lt;BR /&gt;
1003 C&lt;BR /&gt;
1003 P&lt;BR /&gt;
1004 C&lt;BR /&gt;
1004 P&lt;BR /&gt;
&lt;BR /&gt;
if a phyid has C and P and we need only P to be displayed like 1003 and 1004 only P are displayed.&lt;BR /&gt;
1001 C&lt;BR /&gt;
1002 P&lt;BR /&gt;
1003 P&lt;BR /&gt;
1004 P</description>
      <pubDate>Tue, 21 Sep 2010 19:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73676#M15857</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-09-21T19:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73677#M15858</link>
      <description>Hi:&lt;BR /&gt;
  Do you want an output dataset or do you want a report??? And if you want a report, what is your destination of interest? If you want a dataset, do you just want to drop the obs for the phyid that has both C and P???&lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 21 Sep 2010 19:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73677#M15858</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-09-21T19:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73678#M15859</link>
      <description>Need dataset.If a phyid has a flag 'C' and 'P' i need only that record for 'P'.&lt;BR /&gt;
1001 C&lt;BR /&gt;
1002 P&lt;BR /&gt;
1003 C&lt;BR /&gt;
1003 P&lt;BR /&gt;
1004 P&lt;BR /&gt;
1004 C&lt;BR /&gt;
&lt;BR /&gt;
the output:&lt;BR /&gt;
1001 C&lt;BR /&gt;
1002 P&lt;BR /&gt;
1003 P&lt;BR /&gt;
1004 P</description>
      <pubDate>Tue, 21 Sep 2010 19:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73678#M15859</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-09-21T19:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73679#M15860</link>
      <description>You could do this with two sorts.  The first sort by phyid and descending flag.  The second sort just by phyid and use the nodupkey option.</description>
      <pubDate>Tue, 21 Sep 2010 19:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73679#M15860</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-09-21T19:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73680#M15861</link>
      <description>@polingjw: Here is another way, taking advantage of proc sql's automatic re-merging of the summary statistics:&lt;BR /&gt;
[pre]&lt;BR /&gt;
   /* test data by polingjw */&lt;BR /&gt;
   data test;&lt;BR /&gt;
     input phyid flag $;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
   1001 C&lt;BR /&gt;
   1002 P&lt;BR /&gt;
   1003 C&lt;BR /&gt;
   1003 P&lt;BR /&gt;
   1004 C&lt;BR /&gt;
   1004 P&lt;BR /&gt;
   ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   proc sql;&lt;BR /&gt;
     create table test2 as&lt;BR /&gt;
     select phyid, flag, sum(flag="C") as c, sum(flag="P") as p&lt;BR /&gt;
     from   test&lt;BR /&gt;
     group by phyid;&lt;BR /&gt;
&lt;BR /&gt;
     /* print out an obs if the id has only C or P;&lt;BR /&gt;
        the flag="P" obs if the id has both */&lt;BR /&gt;
     select * from test2 &lt;BR /&gt;
     where (c and not p) or (not c and p) or (c and p and flag="P");&lt;BR /&gt;
     /* on lst&lt;BR /&gt;
      phyid  flag             c         p&lt;BR /&gt;
     --------------------------------------&lt;BR /&gt;
       1001  C                1         0&lt;BR /&gt;
       1002  P                0         1&lt;BR /&gt;
       1003  P                1         1&lt;BR /&gt;
       1004  P                1         1&lt;BR /&gt;
     */&lt;BR /&gt;
   quit;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 21 Sep 2010 21:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73680#M15861</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-09-21T21:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Phyid and Flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73681#M15862</link>
      <description>This is interesting.Thanks for the help.</description>
      <pubDate>Wed, 22 Sep 2010 13:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phyid-and-Flag/m-p/73681#M15862</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-09-22T13:17:25Z</dc:date>
    </item>
  </channel>
</rss>

