<?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 Programming issue for counting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Programming-issue-for-counting/m-p/588414#M168158</link>
    <description>&lt;DIV class="branch"&gt;Hi Madam/Sir,&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to count the number of observations when ind_dir=1 in the same company (cikcode) and in the same year (annualreportdate). The following code was tried and printed. However, as shown in the excel sheet containing data, the whole observation per company-year was counted regardless whether ind_dir=1 or ind_dir=0. How can I fix the program to count the number of observations only when ind_dir=1 per company-year pair?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;163 proc sql;&lt;BR /&gt;163! create table count1 as select*, count(ind_dir=1) as dirindsum from os5 group by&lt;BR /&gt;163! cikcode, annualreportdate; run;&lt;BR /&gt;NOTE: The query requires remerging summary statistics back with the original data.&lt;BR /&gt;NOTE: Table WORK.COUNT1 created, with 2474560 rows and 40 columns.&lt;/P&gt;&lt;P&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;BR /&gt;164&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 8:43.94&lt;BR /&gt;cpu time 1:09.04&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;165 proc print data=count1(obs=1000); var cikcode annualreportdate ind_dir dirindsum; run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1000 observations read from the data set WORK.COUNT1.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.32 seconds&lt;BR /&gt;cpu time 0.31 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIncerely,&lt;/P&gt;&lt;P&gt;Joon1&lt;/P&gt;&lt;TABLE border="0" cellspacing="1" cellpadding="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 13 Sep 2019 01:35:11 GMT</pubDate>
    <dc:creator>joon1</dc:creator>
    <dc:date>2019-09-13T01:35:11Z</dc:date>
    <item>
      <title>Programming issue for counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Programming-issue-for-counting/m-p/588414#M168158</link>
      <description>&lt;DIV class="branch"&gt;Hi Madam/Sir,&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to count the number of observations when ind_dir=1 in the same company (cikcode) and in the same year (annualreportdate). The following code was tried and printed. However, as shown in the excel sheet containing data, the whole observation per company-year was counted regardless whether ind_dir=1 or ind_dir=0. How can I fix the program to count the number of observations only when ind_dir=1 per company-year pair?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;163 proc sql;&lt;BR /&gt;163! create table count1 as select*, count(ind_dir=1) as dirindsum from os5 group by&lt;BR /&gt;163! cikcode, annualreportdate; run;&lt;BR /&gt;NOTE: The query requires remerging summary statistics back with the original data.&lt;BR /&gt;NOTE: Table WORK.COUNT1 created, with 2474560 rows and 40 columns.&lt;/P&gt;&lt;P&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;BR /&gt;164&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 8:43.94&lt;BR /&gt;cpu time 1:09.04&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;165 proc print data=count1(obs=1000); var cikcode annualreportdate ind_dir dirindsum; run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1000 observations read from the data set WORK.COUNT1.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.32 seconds&lt;BR /&gt;cpu time 0.31 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SIncerely,&lt;/P&gt;&lt;P&gt;Joon1&lt;/P&gt;&lt;TABLE border="0" cellspacing="1" cellpadding="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Sep 2019 01:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Programming-issue-for-counting/m-p/588414#M168158</guid>
      <dc:creator>joon1</dc:creator>
      <dc:date>2019-09-13T01:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Programming issue for counting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Programming-issue-for-counting/m-p/588423#M168164</link>
      <description>&lt;P&gt;Hope this help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table count1 as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct cikcode, annualreportdate, count(*) as dirindsum&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from os5 where ind_dir=1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by cikcode, annualreportdate&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 03:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Programming-issue-for-counting/m-p/588423#M168164</guid>
      <dc:creator>hlnquynh</dc:creator>
      <dc:date>2019-09-13T03:02:08Z</dc:date>
    </item>
  </channel>
</rss>

