<?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 how to count the number of observations that meet certain conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129850#M260537</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I always want to count the number of observations/list these observations that meet certain conditions I define. But I don't really know how to do it. For example, I have the following dataset. I want to find # of observations that firm=1 &amp;amp; dummy=B &amp;amp; assets=10, and list those observations. This seems to be easy as a short dataset, but if there are more than 1 million observations, it will be much more difficult. So I wonder if there is any procedure or other command that will run this purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; firm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dummy$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assets&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Oct 2013 03:54:49 GMT</pubDate>
    <dc:creator>SeanZ</dc:creator>
    <dc:date>2013-10-31T03:54:49Z</dc:date>
    <item>
      <title>how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129850#M260537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I always want to count the number of observations/list these observations that meet certain conditions I define. But I don't really know how to do it. For example, I have the following dataset. I want to find # of observations that firm=1 &amp;amp; dummy=B &amp;amp; assets=10, and list those observations. This seems to be easy as a short dataset, but if there are more than 1 million observations, it will be much more difficult. So I wonder if there is any procedure or other command that will run this purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; firm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dummy$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assets&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 03:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129850#M260537</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-10-31T03:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129851#M260538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use quite a few SAS Procedures for this (Proc Means/Summary, Proc Report, Proc Tabulate,....).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here some code using Proc SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select count(*) as N_Obs&lt;/P&gt;&lt;P&gt;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; where firm=1 and dummy='B' and assets=10&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 04:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129851#M260538</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-31T04:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129852#M260539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. But is it possible to list what are they? And what (*) means here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129852#M260539</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-10-31T05:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129853#M260540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have SAS EG then I suggest you use the Query Builder Wizard and "play around" with it until you get the result you want. After that look at the code generated by the wizard and eventually use the SAS Online Doc (Proc SQL) to understand the syntax.&lt;/P&gt;&lt;P&gt;Your questions are very basic so I feel you probably should first invest a bit of time in learning SAS and SQL language.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 07:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129853#M260540</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-31T07:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129854#M260541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Nov 2013 07:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/129854#M260541</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-11-03T07:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the number of observations that meet certain conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/322738#M260542</link>
      <description>&lt;P&gt;Patrik,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for this solution. &amp;nbsp;If I could, I wish to know how to assign N_Obs to a macro var such as &amp;amp;nobs or to a universal variable. Is that somthing that can be done within the proc sql?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-number-of-observations-that-meet-certain/m-p/322738#M260542</guid>
      <dc:creator>jakestat</dc:creator>
      <dc:date>2017-01-05T17:45:38Z</dc:date>
    </item>
  </channel>
</rss>

