<?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: Why wouldn't my COUNT() statement work in PROC SQL? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11615#M1408</link>
    <description>For simple counting reports, I always turn to PROC FREQ. For example, if I want to know how many products were sold for each REGION in SASHELP.SHOES, I can do this, using BY group processing:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes;&lt;BR /&gt;
  by region;&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
ods html file='c:\temp\shoe_count.html' style=sasweb;&lt;BR /&gt;
proc freq data=shoes;&lt;BR /&gt;
  by region;&lt;BR /&gt;
  table product;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Just as you can have more variables listed in a GROUP BY for PROC SQL, you can have more than one BY variable used for BY group processing. So your PROC FREQ could have BY ID_NUM CYCLE for your PROC FREQ.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Wed, 28 Apr 2010 16:16:15 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-04-28T16:16:15Z</dc:date>
    <item>
      <title>Why wouldn't my COUNT() statement work in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11613#M1406</link>
      <description>It will run without the COUNT() statement but with it there, it won't run. It's so frustrating; I can't figure out why! TMISSING variable has either 'YES' or 'NO' and I want to count how many YES's per cycle per person (ID_NUM).&lt;BR /&gt;
&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE SUBJECT AS&lt;BR /&gt;
SELECT DISTINCT ID_NUM AS ID, CYCLE LENGTH=5, TMISSING LENGTH=8,&lt;BR /&gt;
COUNT(DISTINCT TMISSING='YES') AS COUNT LENGTH=5&lt;BR /&gt;
FROM STACKED_DENTAL&lt;BR /&gt;
GROUP BY ID_NUM, CYCLE;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
PROC PRINT DATA=SUBJECT;&lt;BR /&gt;
RUN;</description>
      <pubDate>Wed, 28 Apr 2010 15:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11613#M1406</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-28T15:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why wouldn't my COUNT() statement work in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11614#M1407</link>
      <description>COUNT(DISTINCT TMISSING='YES')  should return 2 since the distinct values of the logical result of (TMISSING='YES') would be True and False. so 2 distinct values.

SUM(DISTINCT TMISSING='YES') should give you what you want&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Flip</description>
      <pubDate>Wed, 28 Apr 2010 16:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11614#M1407</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-04-28T16:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why wouldn't my COUNT() statement work in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11615#M1408</link>
      <description>For simple counting reports, I always turn to PROC FREQ. For example, if I want to know how many products were sold for each REGION in SASHELP.SHOES, I can do this, using BY group processing:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes;&lt;BR /&gt;
  by region;&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
ods html file='c:\temp\shoe_count.html' style=sasweb;&lt;BR /&gt;
proc freq data=shoes;&lt;BR /&gt;
  by region;&lt;BR /&gt;
  table product;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Just as you can have more variables listed in a GROUP BY for PROC SQL, you can have more than one BY variable used for BY group processing. So your PROC FREQ could have BY ID_NUM CYCLE for your PROC FREQ.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 28 Apr 2010 16:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Why-wouldn-t-my-COUNT-statement-work-in-PROC-SQL/m-p/11615#M1408</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-04-28T16:16:15Z</dc:date>
    </item>
  </channel>
</rss>

