<?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: Count and Sum total in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547686#M8416</link>
    <description>&lt;P&gt;Can it be done in two steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2019 18:26:20 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-04-01T18:26:20Z</dc:date>
    <item>
      <title>Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547678#M8414</link>
      <description>&lt;P&gt;Id&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;b&lt;/P&gt;&lt;P&gt;How to get counts of id and then sum the total number of id's and display the below format in a table?&lt;/P&gt;&lt;P&gt;a b c total&lt;BR /&gt;3 4 2 9&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 18:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547678#M8414</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-04-01T18:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547686#M8416</link>
      <description>&lt;P&gt;Can it be done in two steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 18:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547686#M8416</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-01T18:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547688#M8418</link>
      <description>&lt;P&gt;One way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Id $;
datalines;
a
b
c
a
b
a
b
c
b
;

proc freq data=have;
   tables Id / out=temp;
run;

proc transpose data=temp out=tempwide;
    id Id;
    var count;
run;

data want;
   set tempwide(keep=_NUMERIC_);
   total=sum(of _NUMERIC_);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 18:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547688#M8418</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-04-01T18:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547701#M8419</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Id $;
cards;
a
b
c
a
b
a
b
c
b
;

/*Need this step for horizontal variables names*/
proc sql noprint;
select distinct id,count(distinct id)  into :vars separated by ' ',:c
from have;
quit;
/*straight forward look up and count*/
data want;
set have end=lr;
array names(&amp;amp;c) &amp;amp;vars;
array temp(&amp;amp;c) $ _temporary_ ;
if _n_=1 then do _n_=1 to dim(temp);
temp(_n_)=vname(names(_n_));
end;
names(whichc(id,of temp(*)))+1;
if lr;
total=sum(of names(*));
output;
drop id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 19:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547701#M8419</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-01T19:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547706#M8420</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Id&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;b&lt;/P&gt;
&lt;P&gt;How to get counts of id and then sum the total number of id's and display the below format in a table?&lt;/P&gt;
&lt;P&gt;a b c total&lt;BR /&gt;3 4 2 9&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about:&lt;/P&gt;
&lt;PRE&gt;data have;
input Id $;
datalines;
a
b
c
a
b
a
b
c
b
;
run;

proc tabulate data=have;
   class id;
   table n='',
         id='' All='Total'
         /row=float
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 19:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547706#M8420</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-01T19:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Count and Sum total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547708#M8421</link>
      <description>&lt;P&gt;"Speak of the SAS genie", I was just mentioning to a mate that you will come up with a proc tabulate and you did. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Kudos to me for predicting haha and you lol&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 19:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Count-and-Sum-total/m-p/547708#M8421</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-01T19:27:55Z</dc:date>
    </item>
  </channel>
</rss>

