<?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: PROC PRINT sum A by B in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38105#M9732</link>
    <description>wow&lt;BR /&gt;
5 minutes and 3 substantial responses&lt;BR /&gt;
what a channel!</description>
    <pubDate>Thu, 24 Mar 2011 20:03:03 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2011-03-24T20:03:03Z</dc:date>
    <item>
      <title>PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38099#M9726</link>
      <description>I am trying to use PROC PRINT to output sum variable A by variable B with an external printto reference.  There are many distinct values of A for each B.  &lt;BR /&gt;
&lt;BR /&gt;
I have attempted to use:&lt;BR /&gt;
proc print data=x;&lt;BR /&gt;
sum A;&lt;BR /&gt;
by B;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have insight of a better way to achieve the goal of outputting sum A by B?</description>
      <pubDate>Thu, 24 Mar 2011 17:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38099#M9726</guid>
      <dc:creator>jdub</dc:creator>
      <dc:date>2011-03-24T17:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38100#M9727</link>
      <description>Can you provide sample inbound and outbound data sets so that we can better determine your question.</description>
      <pubDate>Thu, 24 Mar 2011 18:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38100#M9727</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-03-24T18:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38101#M9728</link>
      <description>A mockup of data x is below.  I am trying to suppress the observations in the output so sum values print for A, B and C.  If I use noobs after proc print the obs. record number is suppressed but the list of obs. still posts.&lt;BR /&gt;
&lt;BR /&gt;
I am just looking for sums.&lt;BR /&gt;
&lt;BR /&gt;
I would like to generate &lt;BR /&gt;
sum A = 41&lt;BR /&gt;
sum B = 45&lt;BR /&gt;
sum C = ..&lt;BR /&gt;
&lt;BR /&gt;
data x:&lt;BR /&gt;
A	B&lt;BR /&gt;
1	12&lt;BR /&gt;
1	14&lt;BR /&gt;
1	15&lt;BR /&gt;
2	3&lt;BR /&gt;
2	9&lt;BR /&gt;
2	10&lt;BR /&gt;
2	12&lt;BR /&gt;
2	11&lt;BR /&gt;
3	66&lt;BR /&gt;
3	71&lt;BR /&gt;
3	23&lt;BR /&gt;
3	8&lt;BR /&gt;
3	9&lt;BR /&gt;
&lt;BR /&gt;
What I get is:&lt;BR /&gt;
&lt;BR /&gt;
12&lt;BR /&gt;
14&lt;BR /&gt;
15&lt;BR /&gt;
__A SUM__&lt;BR /&gt;
41</description>
      <pubDate>Thu, 24 Mar 2011 18:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38101#M9728</guid>
      <dc:creator>jdub</dc:creator>
      <dc:date>2011-03-24T18:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38102#M9729</link>
      <description>&amp;gt; data x:&lt;BR /&gt;
&amp;gt; A	B&lt;BR /&gt;
&amp;gt; 1	12&lt;BR /&gt;
&amp;gt; 1	14&lt;BR /&gt;
&amp;gt; 1	15&lt;BR /&gt;
&amp;gt; 2	3&lt;BR /&gt;
&amp;gt; 2	9&lt;BR /&gt;
&amp;gt; 2	10&lt;BR /&gt;
&amp;gt; 2	12&lt;BR /&gt;
&amp;gt; 2	11&lt;BR /&gt;
&amp;gt; 3	66&lt;BR /&gt;
&amp;gt; 3	71&lt;BR /&gt;
&amp;gt; 3	23&lt;BR /&gt;
&amp;gt; 3	8&lt;BR /&gt;
&amp;gt; 3	9&lt;BR /&gt;
&lt;BR /&gt;
proc means data= x ;&lt;BR /&gt;
class a ;&lt;BR /&gt;
var b ;&lt;BR /&gt;
output sum= out= x_summary ;&lt;BR /&gt;
run;&lt;BR /&gt;
then choose what to do with the summary totals in data set x_summary.&lt;BR /&gt;
Output data set x_summary will hold the total value of B for each value of A.&lt;BR /&gt;
The variables will be:&lt;BR /&gt;
A&lt;BR /&gt;
B (being the sum of B within A )&lt;BR /&gt;
_freq_  (the number of rows in X for the current value of A)&lt;BR /&gt;
_type_ (=0 for overall total and 1 for the total lines of each A)&lt;BR /&gt;
better documentation can be found at &lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/allprodsproc/63875/HTML/default/a003135046.htm#a003145681" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/allprodsproc/63875/HTML/default/a003135046.htm#a003145681&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
peterC</description>
      <pubDate>Thu, 24 Mar 2011 18:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38102#M9729</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-24T18:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38103#M9730</link>
      <description>Hello Jdub,&lt;BR /&gt;
&lt;BR /&gt;
I guess that you need something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc means data=x nway noprint;&lt;BR /&gt;
  output out=sum(drop=_:) sum=;&lt;BR /&gt;
  var b;&lt;BR /&gt;
  class a;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data=sum;&lt;BR /&gt;
  id a;&lt;BR /&gt;
  var b;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 24 Mar 2011 18:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38103#M9730</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-24T18:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38104#M9731</link>
      <description>Hi:&lt;BR /&gt;
  It seems to me that you do not want a DETAIL report (where you see 1 report row for every observation in the original input data). You describe a SUMMARY report (where  every report row represents the information for a group of observations).&lt;BR /&gt;
&lt;BR /&gt;
  SAS has many, many summary-level procedures: PROC SQL, PROC MEANS, PROC TABULATE, PROC REPORT. &lt;BR /&gt;
 &lt;BR /&gt;
  Depending on what you want to do (generate output dataset or generate an HTML, RTF or PDF report), you might try starting with PROC MEANS and then graduate to TABULATE or REPORT if MEANS isn't what you want.&lt;BR /&gt;
&lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods html file='c:\temp\examp_means.html' style=sasweb;&lt;BR /&gt;
proc means data=x sum maxdec=0;&lt;BR /&gt;
  var a b;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 24 Mar 2011 18:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38104#M9731</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-03-24T18:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38105#M9732</link>
      <description>wow&lt;BR /&gt;
5 minutes and 3 substantial responses&lt;BR /&gt;
what a channel!</description>
      <pubDate>Thu, 24 Mar 2011 20:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38105#M9732</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-24T20:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC PRINT sum A by B</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38106#M9733</link>
      <description>data x;&lt;BR /&gt;
 infile datalines dlm='09'x;&lt;BR /&gt;
 input a b :8.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1	12&lt;BR /&gt;
1	14&lt;BR /&gt;
1	15&lt;BR /&gt;
2	3&lt;BR /&gt;
2	9&lt;BR /&gt;
2	10&lt;BR /&gt;
2	12&lt;BR /&gt;
2	11&lt;BR /&gt;
3	66&lt;BR /&gt;
3	71&lt;BR /&gt;
3	23&lt;BR /&gt;
3	8&lt;BR /&gt;
3	9&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=x out=y; &lt;BR /&gt;
 var a b;&lt;BR /&gt;
 table a*sum b*sum;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=y(keep=a_sum b_sum) out=z; run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=z noobs; run;&lt;BR /&gt;
&lt;BR /&gt;
Output:&lt;BR /&gt;
&lt;BR /&gt;
a_Sum   28&lt;BR /&gt;
b_Sum  263</description>
      <pubDate>Thu, 24 Mar 2011 21:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-PRINT-sum-A-by-B/m-p/38106#M9733</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-03-24T21:22:19Z</dc:date>
    </item>
  </channel>
</rss>

