<?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 Count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66650#M14468</link>
    <description>proc sql;&lt;BR /&gt;
   create table hhs_combine_bsm_final as&lt;BR /&gt;
    select d1.*,&lt;BR /&gt;
        case &lt;BR /&gt;
      when d1.phy_name eq d2.physician_name and d1.phy_name  ne '' then 'Y'&lt;BR /&gt;
	end as flag&lt;BR /&gt;
      from HHS_combine_bsm d1 left outer join exclude_v1  d2 on d1.phy_name=d2.physician_name;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Say for the above code we get the data as below:&lt;BR /&gt;
terrid	phyname	               flag&lt;BR /&gt;
903110	SAMY BUNN	Y&lt;BR /&gt;
903110	david Herr	&lt;BR /&gt;
903110	peter pan	&lt;BR /&gt;
903110	samuel colt	&lt;BR /&gt;
9031101	sarah	               Y&lt;BR /&gt;
9031101	williams	               Y&lt;BR /&gt;
9031101	scott	&lt;BR /&gt;
9031101	tramp	&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How to delete or not display if there is only one physician per terrid  whose flag is 'Y'.&lt;BR /&gt;
for instance we dont want SAMY BUNN, in terrid 930110 as he is the only one physician in that terrid whose flag is 'Y'.</description>
    <pubDate>Mon, 24 Aug 2009 17:38:39 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-08-24T17:38:39Z</dc:date>
    <item>
      <title>Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66650#M14468</link>
      <description>proc sql;&lt;BR /&gt;
   create table hhs_combine_bsm_final as&lt;BR /&gt;
    select d1.*,&lt;BR /&gt;
        case &lt;BR /&gt;
      when d1.phy_name eq d2.physician_name and d1.phy_name  ne '' then 'Y'&lt;BR /&gt;
	end as flag&lt;BR /&gt;
      from HHS_combine_bsm d1 left outer join exclude_v1  d2 on d1.phy_name=d2.physician_name;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Say for the above code we get the data as below:&lt;BR /&gt;
terrid	phyname	               flag&lt;BR /&gt;
903110	SAMY BUNN	Y&lt;BR /&gt;
903110	david Herr	&lt;BR /&gt;
903110	peter pan	&lt;BR /&gt;
903110	samuel colt	&lt;BR /&gt;
9031101	sarah	               Y&lt;BR /&gt;
9031101	williams	               Y&lt;BR /&gt;
9031101	scott	&lt;BR /&gt;
9031101	tramp	&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
How to delete or not display if there is only one physician per terrid  whose flag is 'Y'.&lt;BR /&gt;
for instance we dont want SAMY BUNN, in terrid 930110 as he is the only one physician in that terrid whose flag is 'Y'.</description>
      <pubDate>Mon, 24 Aug 2009 17:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66650#M14468</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-24T17:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66651#M14469</link>
      <description>proc sql;&lt;BR /&gt;
  create table two as select b.* from hhs_combine_bsm_final  b&lt;BR /&gt;
 where b.terrid in (select a.terrid from (select terrid, count(flg) as cf from hhs_combine_bsm_final &lt;BR /&gt;
 where flg = 'Y'  group by terrid)  a&lt;BR /&gt;
       where  a.cf &amp;gt; 1);&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 24 Aug 2009 18:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66651#M14469</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-08-24T18:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66652#M14470</link>
      <description>Flip,&lt;BR /&gt;
   Its returing all the values without the filter</description>
      <pubDate>Mon, 24 Aug 2009 18:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66652#M14470</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-24T18:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66653#M14471</link>
      <description>I tested it again and am getting the desired result.  I did spell flag differently from you.  Run each subquerry alone and check.&lt;BR /&gt;
&lt;BR /&gt;
 data one;&lt;BR /&gt;
  input  terrid $ phys $ flag $;&lt;BR /&gt;
cards;&lt;BR /&gt;
123 aaa Y&lt;BR /&gt;
123 bbb n&lt;BR /&gt;
123 ccc n&lt;BR /&gt;
456 hhh n&lt;BR /&gt;
456 jjj n&lt;BR /&gt;
456 kkk Y&lt;BR /&gt;
456 lll Y&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table two as select b.* from one b where b.terrid in&lt;BR /&gt;
(select a.terrid from (select terrid, count(flag) as cf from one&lt;BR /&gt;
where flag = 'Y' group by terrid) a where a.cf &amp;gt; 1);&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
                                                                 14:23 Monday, August 24, 2009   &lt;BR /&gt;
&lt;BR /&gt;
Obs    terrid    phys    flag&lt;BR /&gt;
&lt;BR /&gt;
 1      456      hhh      n&lt;BR /&gt;
 2      456      jjj      n&lt;BR /&gt;
 3      456      kkk      Y&lt;BR /&gt;
 4      456      lll      Y</description>
      <pubDate>Mon, 24 Aug 2009 18:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66653#M14471</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-08-24T18:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66654#M14472</link>
      <description>Flip,&lt;BR /&gt;
 We need the terrid, but we do not need the phys.we do not want aaa in 123, bu we want bbb and ccc from 123.&lt;BR /&gt;
&lt;BR /&gt;
so output looks like:&lt;BR /&gt;
123                      bbb       n&lt;BR /&gt;
123                      ccc       n&lt;BR /&gt;
456                       hhh       n&lt;BR /&gt;
456                        jjj         n&lt;BR /&gt;
456                        kkk      Y&lt;BR /&gt;
456                         lll         Y</description>
      <pubDate>Mon, 24 Aug 2009 18:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66654#M14472</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-24T18:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66655#M14473</link>
      <description>proc sql;&lt;BR /&gt;
create table two as select b.* from one b where b.terrid in&lt;BR /&gt;
(select a.terrid from (select terrid, count(flag) as cf from one&lt;BR /&gt;
where flag = 'Y' group by terrid) a where a.cf &amp;gt; 1 OR FLAG ne 'Y'   );&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 24 Aug 2009 19:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count/m-p/66655#M14473</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-08-24T19:34:06Z</dc:date>
    </item>
  </channel>
</rss>

