<?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 calculations in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363078#M85875</link>
    <description>&lt;P&gt;(I know I should know this). I want to get rid of the hard coded number (10021). This number equals the number of records in the data set.&lt;/P&gt;
&lt;P&gt;My objective is to count the number of obs in each efaprimary category listed in the WHERE clause and then get a percentage that it represents of the entire data set. In other words, there are some efaprimary codes not included in the report but I need to count those obs to use in the denominator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;SELECT d.efaprimary, count(efaprimary) as Ncount,&lt;BR /&gt;calculated Ncount/&lt;STRONG&gt;10021&lt;/STRONG&gt; as Pct format=percent8.2&lt;BR /&gt;FROM d45 as d&lt;BR /&gt;WHERE enroll_status='0' and grade_level not in ('-1','-2')&amp;nbsp;and efaprimary in ('*DD','*OHI','*PMD','*TBI','AU','EH','EM','HH','LD','OH','SP','TM','VH')&lt;BR /&gt;GROUP BY efaprimary;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 14:01:45 GMT</pubDate>
    <dc:creator>GreggB</dc:creator>
    <dc:date>2017-05-31T14:01:45Z</dc:date>
    <item>
      <title>calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363078#M85875</link>
      <description>&lt;P&gt;(I know I should know this). I want to get rid of the hard coded number (10021). This number equals the number of records in the data set.&lt;/P&gt;
&lt;P&gt;My objective is to count the number of obs in each efaprimary category listed in the WHERE clause and then get a percentage that it represents of the entire data set. In other words, there are some efaprimary codes not included in the report but I need to count those obs to use in the denominator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;SELECT d.efaprimary, count(efaprimary) as Ncount,&lt;BR /&gt;calculated Ncount/&lt;STRONG&gt;10021&lt;/STRONG&gt; as Pct format=percent8.2&lt;BR /&gt;FROM d45 as d&lt;BR /&gt;WHERE enroll_status='0' and grade_level not in ('-1','-2')&amp;nbsp;and efaprimary in ('*DD','*OHI','*PMD','*TBI','AU','EH','EM','HH','LD','OH','SP','TM','VH')&lt;BR /&gt;GROUP BY efaprimary;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363078#M85875</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2017-05-31T14:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363080#M85876</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select nobs into :nobs from dictionary.tables where libname = 'WORK' and upcase(memname) = 'D45';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use &amp;amp;nobs instead of 10021.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363080#M85876</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-31T14:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363081#M85877</link>
      <description>&lt;P&gt;should "info" be "in" ?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363081#M85877</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2017-05-31T14:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363082#M85878</link>
      <description>&lt;P&gt;One way would be to include the total n as a subquerry. e.g.:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  SELECT d.sex, count(sex) as Ncount,
    (select count(*) from sashelp.class) as total,
    calculated Ncount/calculated total as Pct format=percent8.2
      FROM sashelp.class as d
        WHERE age le 12
          GROUP BY sex
  ;
QUIT;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363082#M85878</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-31T14:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363083#M85879</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363083#M85879</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2017-05-31T14:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: calculations in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363084#M85880</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13712"&gt;@GreggB&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;should "info" be "in" ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, it should be "into". Typo, fixed it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 14:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculations-in-PROC-SQL/m-p/363084#M85880</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-31T14:18:40Z</dc:date>
    </item>
  </channel>
</rss>

