<?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 Creating a table of sums by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90765#M289722</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some data similar to what I've put below (only with many more variables and millions of records). I need some code to create a sum of the amount by region. I am aware of the proc print command that does this but I don't want to see a list of the observations for each region as there will be far too many (due to the millions of records). Ideally a new table with this information would be created or some way that I could reference these sums directly for a following piece of code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I haven't made myself clear enough and more clarification is needed then feel free to ask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data proctest ; &lt;/P&gt;&lt;P&gt;input age region $ amount ; &lt;/P&gt;&lt;P&gt;datalines ; &lt;/P&gt;&lt;P&gt;23 NE 364364&lt;/P&gt;&lt;P&gt;45 NW 483933&lt;/P&gt;&lt;P&gt;67 SE 383932&lt;/P&gt;&lt;P&gt;43 NE 483022&lt;/P&gt;&lt;P&gt;54 L 666602&lt;/P&gt;&lt;P&gt;22 SW 483392&lt;/P&gt;&lt;P&gt;77 E 111111&lt;/P&gt;&lt;P&gt;34 SE 292093&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Dec 2012 09:30:11 GMT</pubDate>
    <dc:creator>AnEmu</dc:creator>
    <dc:date>2012-12-05T09:30:11Z</dc:date>
    <item>
      <title>Creating a table of sums by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90765#M289722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some data similar to what I've put below (only with many more variables and millions of records). I need some code to create a sum of the amount by region. I am aware of the proc print command that does this but I don't want to see a list of the observations for each region as there will be far too many (due to the millions of records). Ideally a new table with this information would be created or some way that I could reference these sums directly for a following piece of code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I haven't made myself clear enough and more clarification is needed then feel free to ask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data proctest ; &lt;/P&gt;&lt;P&gt;input age region $ amount ; &lt;/P&gt;&lt;P&gt;datalines ; &lt;/P&gt;&lt;P&gt;23 NE 364364&lt;/P&gt;&lt;P&gt;45 NW 483933&lt;/P&gt;&lt;P&gt;67 SE 383932&lt;/P&gt;&lt;P&gt;43 NE 483022&lt;/P&gt;&lt;P&gt;54 L 666602&lt;/P&gt;&lt;P&gt;22 SW 483392&lt;/P&gt;&lt;P&gt;77 E 111111&lt;/P&gt;&lt;P&gt;34 SE 292093&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 09:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90765#M289722</guid>
      <dc:creator>AnEmu</dc:creator>
      <dc:date>2012-12-05T09:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table of sums by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90766#M289723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc means (or proc summary) will provide the data you want provided you specify sum, and use the statement Class region.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach is to use SQL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table totals as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct region&lt;/P&gt;&lt;P&gt;&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; ,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(amount) as total&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proctest&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by region &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Quit ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 11:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90766#M289723</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-12-05T11:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table of sums by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90767#M289724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RichardinOz's hint of proc means or summary is probably easiest to code if you want to summarize many variables as it allows the use of variable lists and such.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc means data=have noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class region;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var amount1 - amount100;&amp;nbsp; /* or such as _numeric_ as long your class variable isn't numeric, or v: for all variables starting with v */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=want sum=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;There will be a variable _type_ that has levels of the class variable with the value of 0 indicating the overall total sum as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 16:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-of-sums-by-group/m-p/90767#M289724</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-05T16:14:00Z</dc:date>
    </item>
  </channel>
</rss>

