<?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: distinct counts using proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277812#M58787</link>
    <description>&lt;P&gt;Well guessing again:&lt;/P&gt;
&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;
&lt;P&gt;&amp;nbsp; select&amp;nbsp;&lt;SPAN&gt;product, comp, count(subj) as result&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; from &amp;nbsp; HAVE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; group by&amp;nbsp;product, comp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 08:50:36 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-06-16T08:50:36Z</dc:date>
    <item>
      <title>distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277807#M58782</link>
      <description>&lt;P&gt;i am using the below code to display and count distinct subjects but i get the same number for all 3 reportings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table inc as&lt;BR /&gt; select distinct reporting, product, comparator, comparator2, randomisation_scheme,&lt;BR /&gt; "All Subjects" as txt,count(distinct subj_id) as cnt&lt;BR /&gt; from subj&lt;BR /&gt; order by trl_id_reporting;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me on this&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277807#M58782</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-06-16T08:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277808#M58783</link>
      <description>&lt;P&gt;To do aggregates in SQL you use the keywords;&lt;/P&gt;
&lt;P&gt;group by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your code will not work, you are refering to variables that are not in the select clause, maybe you want: something like the below - its hard to say as you have not posted any test data (in the form of a datastep) and what the output should look like, so we are guessing.&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table INC as
  select REPORTING,
            PRODUCT,
            COMPARATOR,
            COMPARATOR2,
            RANDOMISATION_SCHEME,
            "All Subjects" as TXT,
            count(distinct SUBJ_ID) as CNT
  from   SUBJ
  group by REPORTING,
                 PRODUCT,
                 COMPARATOR,
                COMPARATOR2,
                 RANDOMISATION_SCHEME,
                "All Subjects";
quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277808#M58783</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-16T08:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277809#M58784</link>
      <description>&lt;P&gt;I tried it but it didnt work as i will get all the 400 obs. i used distinct before reporting but still no luck&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277809#M58784</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-06-16T08:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277810#M58785</link>
      <description>&lt;P&gt;Sorry, I have no idea what your talking about. &amp;nbsp;Post test&amp;nbsp;data - in the form of a datastep - and what the output should look like.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277810#M58785</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-16T08:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277811#M58786</link>
      <description>&lt;P&gt;sorry for not being clear output should be distinct of reporting terms with product, comp and there respective number of subjects for each reporting&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277811#M58786</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-06-16T08:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277812#M58787</link>
      <description>&lt;P&gt;Well guessing again:&lt;/P&gt;
&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;
&lt;P&gt;&amp;nbsp; select&amp;nbsp;&lt;SPAN&gt;product, comp, count(subj) as result&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; from &amp;nbsp; HAVE&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; group by&amp;nbsp;product, comp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277812#M58787</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-16T08:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: distinct counts using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277815#M58788</link>
      <description>&lt;P&gt;test data&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 270pt;" border="0" width="360" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 54pt;" span="5" width="72" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD width="72" height="17" class="xl67" style="height: 12.75pt; width: 54pt;"&gt;reporting&lt;/TD&gt;
&lt;TD width="72" class="xl67" style="width: 54pt;"&gt;subjid&lt;/TD&gt;
&lt;TD width="72" class="xl67" style="width: 54pt;"&gt;product&lt;/TD&gt;
&lt;TD width="72" class="xl67" style="width: 54pt;"&gt;comparator&lt;/TD&gt;
&lt;TD width="72" class="xl67" style="width: 54pt;"&gt;comp2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-213&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;2&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins&lt;/TD&gt;
&lt;TD class="xl68"&gt;none&lt;/TD&gt;
&lt;TD class="xl68"&gt;none&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-213&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;1&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins2&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-213&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;23&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins3&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-213&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;11&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins4&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-213&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;21,66667&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins5&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-340&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;26,66667&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins6&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-340&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;31,66667&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins7&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.75pt;"&gt;
&lt;TD height="17" class="xl68" style="height: 12.75pt;"&gt;FSB-340&lt;/TD&gt;
&lt;TD align="right" class="xl68"&gt;36,66667&lt;/TD&gt;
&lt;TD class="xl68"&gt;ins8&lt;/TD&gt;
&lt;TD class="xl68"&gt;pokf&lt;/TD&gt;
&lt;TD class="xl68"&gt;okij&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 16 Jun 2016 08:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/distinct-counts-using-proc-sql/m-p/277815#M58788</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-06-16T08:58:52Z</dc:date>
    </item>
  </channel>
</rss>

