<?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: PROC SQL Select Distinct Count in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264205#M51799</link>
    <description>&lt;P&gt;Use &lt;STRONG&gt;group by&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select sda, ffyear, count (distinct member_id) as count
from ELIGIBLE
group by sda, ffyear;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Apr 2016 15:38:17 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-04-15T15:38:17Z</dc:date>
    <item>
      <title>PROC SQL Select Distinct Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264200#M51796</link>
      <description>&lt;P&gt;Hi Everybody! I am fairly new to SAS and still have trouble with some things.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset and want to get the distinct count of members based on two variables. Variable 1 (SDA) has 13 values and Variable 2 (FFYEAR) HAS 7 values. Instead of writing out the code 91 different times (13 X 7 = 91) for all the different combination of variables, is there a way I can write the code once but refer to all the different values in the variable?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS 9.2 and here is the basic structure of my current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select count (distinct member_id) as count&lt;BR /&gt;from ELIGIBLE&lt;BR /&gt;where sda='A' AND ffyear=2009;&lt;BR /&gt;quit;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to avoid having to write the&amp;nbsp;code over and over for each combination of variable values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 15:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264200#M51796</guid>
      <dc:creator>TXSASneophyte</dc:creator>
      <dc:date>2016-04-15T15:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Select Distinct Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264204#M51798</link>
      <description>&lt;P&gt;I think you need to provide some example data and what you expect the output to look like.&lt;/P&gt;
&lt;P&gt;You may be looking for GROUP BY if you really need to do sql;&lt;/P&gt;
&lt;P&gt;Or possibly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=eligible nway;
   class SDA FFYEAR Member_id;
   output out=want (drop=_type_ rename=(_freq_=Count));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 15:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264204#M51798</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-15T15:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Select Distinct Count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264205#M51799</link>
      <description>&lt;P&gt;Use &lt;STRONG&gt;group by&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select sda, ffyear, count (distinct member_id) as count
from ELIGIBLE
group by sda, ffyear;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 15:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Select-Distinct-Count/m-p/264205#M51799</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-04-15T15:38:17Z</dc:date>
    </item>
  </channel>
</rss>

