<?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: How to sum up one column while keeping the others constant in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229810#M41624</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
    create table want as
         select State, city, food, sum(eligible2) as eligible
            from havetable
     group by state, city, food
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Something like this?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2015 20:54:55 GMT</pubDate>
    <dc:creator>dsbihill</dc:creator>
    <dc:date>2015-10-13T20:54:55Z</dc:date>
    <item>
      <title>How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229808#M41623</link>
      <description>&lt;P&gt;Good afternoon – in the below data set that I have narrowed down, I’m running into the problem of how to sum up 1 column, while keeping the others constant. For example, I want to sum up the # of people that are eligible for MASS, BOSTON, SEAFOOD,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dataset example is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="436"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;&lt;STRONG&gt;STATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;&lt;STRONG&gt;CITY&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;&lt;STRONG&gt;FOOD&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;&lt;STRONG&gt;NAME&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="59"&gt;
&lt;P&gt;&lt;STRONG&gt;Eligible2&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;MASS&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;BOSTON&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;SEAFOOD&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;MARY&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="59"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;MASS&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;BOSTON&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;SEAFOOD&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;FRANK&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="59"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;MASS&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;BOSTON&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;SEAFOOD&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;DAN&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="59"&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;MASS&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;BOSTON&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;SEAFOOD&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;SAM&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="59"&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While what I’m hoping for an output would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="377"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;&lt;STRONG&gt;STATE&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;&lt;STRONG&gt;CITY&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;&lt;STRONG&gt;FOOD&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;&lt;STRONG&gt;Eligible&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="121"&gt;
&lt;P&gt;MASS&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="91"&gt;
&lt;P&gt;BOSTON&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="113"&gt;
&lt;P&gt;SEAFOOD&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="52"&gt;
&lt;P&gt;3&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 20:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229808#M41623</guid>
      <dc:creator>PETE</dc:creator>
      <dc:date>2015-10-13T20:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229810#M41624</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
    create table want as
         select State, city, food, sum(eligible2) as eligible
            from havetable
     group by state, city, food
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Something like this?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 20:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229810#M41624</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2015-10-13T20:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229814#M41625</link>
      <description>&lt;P&gt;Thank you dsbihill. That got me down to just one error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;22&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;/P&gt;
&lt;P&gt;a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT,&lt;/P&gt;
&lt;P&gt;SUBSTRING, USER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 21:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229814#M41625</guid>
      <dc:creator>PETE</dc:creator>
      <dc:date>2015-10-13T21:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229815#M41626</link>
      <description>Can you post your code or the part of the log above the error?  You probably have an extra comma somewhere.</description>
      <pubDate>Tue, 13 Oct 2015 21:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229815#M41626</guid>
      <dc:creator>dsbihill</dc:creator>
      <dc:date>2015-10-13T21:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229858#M41635</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an alternative you can try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data=sashelp.cars nway sum nonobs;&lt;BR /&gt;class make type origin;&lt;BR /&gt;var invoice;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 09:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229858#M41635</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2015-10-14T09:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum up one column while keeping the others constant</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229859#M41636</link>
      <description>&lt;P&gt;Also Proc Summary can be used for purpose like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have sum nway ;&lt;BR /&gt;&amp;nbsp; class State City Food;&lt;BR /&gt;&amp;nbsp; var Eligible2 ;&lt;BR /&gt;&amp;nbsp; output out=want(drop=_type_ _freq_) sum=Eligible; &lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 09:17:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sum-up-one-column-while-keeping-the-others-constant/m-p/229859#M41636</guid>
      <dc:creator>AskoLötjönen</dc:creator>
      <dc:date>2015-10-14T09:17:31Z</dc:date>
    </item>
  </channel>
</rss>

