<?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: Showing total throughout the proc sql or datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Showing-total-throughout-the-proc-sql-or-datastep/m-p/728066#M226554</link>
    <description>&lt;P&gt;Why not try it and see?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table WANT as
  select
    make
  , model
  , type
  , count(*) as count
  from sashelp.cars
  where make in ('Audi')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that will put the count on every observation.&lt;/P&gt;
&lt;P&gt;If you want to count the number by MAKE use GROUP BY&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
select make,count(*) as count
from sashelp.cars
group by make
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just use PROC FREQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars;
tables make;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Mar 2021 01:52:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-03-22T01:52:10Z</dc:date>
    <item>
      <title>Showing total throughout the proc sql or datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Showing-total-throughout-the-proc-sql-or-datastep/m-p/728059#M226549</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;create table have as&lt;BR /&gt;select make,model,type, 1 as count&lt;BR /&gt;from sashelp.cars&lt;BR /&gt;where make in ('Audi');&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code will return 19 records.&amp;nbsp; Would I need to do another proc sql just to get the total to show up (ie&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table have1 ad&lt;/P&gt;
&lt;P&gt;select sum(count) as my_count&lt;/P&gt;
&lt;P&gt;from have&lt;/P&gt;
&lt;P&gt;Is it possible to just show 19 in the count column in the first proc sql rather than the extra proc sql step??&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 01:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Showing-total-throughout-the-proc-sql-or-datastep/m-p/728059#M226549</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-03-22T01:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Showing total throughout the proc sql or datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Showing-total-throughout-the-proc-sql-or-datastep/m-p/728066#M226554</link>
      <description>&lt;P&gt;Why not try it and see?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table WANT as
  select
    make
  , model
  , type
  , count(*) as count
  from sashelp.cars
  where make in ('Audi')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that will put the count on every observation.&lt;/P&gt;
&lt;P&gt;If you want to count the number by MAKE use GROUP BY&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
select make,count(*) as count
from sashelp.cars
group by make
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just use PROC FREQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars;
tables make;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Mar 2021 01:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Showing-total-throughout-the-proc-sql-or-datastep/m-p/728066#M226554</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-22T01:52:10Z</dc:date>
    </item>
  </channel>
</rss>

