<?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: Grouping values and sum up numeric  varaibles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530439#M145064</link>
    <description>&lt;P&gt;I'm assuming that the only purpose of the a. b. notation is to order the formatted values properly?&lt;/P&gt;</description>
    <pubDate>Sun, 27 Jan 2019 09:16:36 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-01-27T09:16:36Z</dc:date>
    <item>
      <title>Grouping values and sum up numeric  varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530437#M145063</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a summary table that is called "table1"&lt;/P&gt;
&lt;P&gt;I need to create a new summary table.&lt;/P&gt;
&lt;P&gt;The new table will group some categories together and sum up the values.&lt;/P&gt;
&lt;P&gt;In the result I expect to have following &amp;nbsp;categories (and for each category to sum customers and obligation values)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; a&lt;/P&gt;
&lt;P&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; All&lt;/P&gt;
&lt;P&gt;2-5 &amp;nbsp; &amp;nbsp;a&lt;/P&gt;
&lt;P&gt;6-7 &amp;nbsp; &amp;nbsp;All&lt;/P&gt;
&lt;P&gt;8-10 &amp;nbsp;All&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; a&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;11 &amp;nbsp; &amp;nbsp; All&lt;/P&gt;
&lt;P&gt;0-11 &amp;nbsp;All&lt;/P&gt;
&lt;P&gt;12 &amp;nbsp; &amp;nbsp;a&lt;/P&gt;
&lt;P&gt;12 &amp;nbsp; &amp;nbsp;b&lt;/P&gt;
&lt;P&gt;12 &amp;nbsp; all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to do it via proc means with proc format but I didn't get the expected results&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data Tbl1;
input grade$   Model$  customers  obligation  ;
cards;
0    a     2000 5000
0    b	 5000 1000
0    All	 7000 6000
2    a	 2000 7000
3    a	 2000 4000
4    a	 2000 3000
5    a	 5000 2000
6    a	 2000 2000
7    a	 3000 1000
8    a	 4000 1000
9    a	 1000 2000
10   a     1000 1000
11   a     3000 3000
11   b     4000 1000
11   All	 7000 4000
0-11 All   36000 33000
12   a     5000 2000
12   b     2000 1000
12   All	 7000 3000
;
Run;


proc format;
value $grade
	'0'='a.0'
	'2','3','4','5'='b.2--5'
	'6','7' ='c.6--7'
	'8','9','10'='d.8--10'
	'11'='e.11'
	'0-11'='f.0-11'
	'12'='g.12'
	 ;
Run;


proc means data=Tbl1 nway noprint;
class grade  Model;
output out=xxx sum= ;
format grade $grade.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 08:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530437#M145063</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-01-27T08:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping values and sum up numeric  varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530439#M145064</link>
      <description>&lt;P&gt;I'm assuming that the only purpose of the a. b. notation is to order the formatted values properly?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Jan 2019 09:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530439#M145064</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-27T09:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping values and sum up numeric  varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530441#M145066</link>
      <description>Yes.exactly. just for order  of categories</description>
      <pubDate>Sun, 27 Jan 2019 09:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530441#M145066</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-01-27T09:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping values and sum up numeric  varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530444#M145068</link>
      <description>&lt;P&gt;Ok. Does this meet your requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Tbl1;
input grade$   Model$  customers  obligation  ;
cards;
0    a     2000 5000
0    b	 5000 1000
0    All	 7000 6000
2    a	 2000 7000
3    a	 2000 4000
4    a	 2000 3000
5    a	 5000 2000
6    a	 2000 2000
7    a	 3000 1000
8    a	 4000 1000
9    a	 1000 2000
10   a     1000 1000
11   a     3000 3000
11   b     4000 1000
11   All	 7000 4000
0-11 All   36000 33000
12   a     5000 2000
12   b     2000 1000
12   All	 7000 3000
;
Run;

proc format;
value $grade
	'0'='a.0'
	'2','3','4','5'='b.2--5'
	'6','7' ='c.6--7'
	'8','9','10'='d.8--10'
	'11'='e.11'
	'0-11'='f.0-11'
	'12'='g.12'
	 ;
Run;


proc means data=Tbl1 nway noprint order=formated;
class grade Model;
output out=xxx(drop=_TYPE_ _FREQ_) sum=;
format grade $grade.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Jan 2019 10:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530444#M145068</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-27T10:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping values and sum up numeric  varaibles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530445#M145069</link>
      <description>&lt;P&gt;Also, since the data seems to be in the order you want in your output already, you can define your PROC FORMAT like this and use ORDER=DATA in the PROC MEANS Statement..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $grade
	'0'='0'
	'2','3','4','5'='2--5'
	'6','7' ='6--7'
	'8','9','10'='8--10'
	'11'='11'
	'0-11'='0-11'
	'12'='12'
	 ;
Run;

proc means data=Tbl1 nway noprint order=data;
class grade Model;
output out=xxx(drop=_TYPE_ _FREQ_) sum=;
format grade $grade.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Jan 2019 10:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-values-and-sum-up-numeric-varaibles/m-p/530445#M145069</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-27T10:08:42Z</dc:date>
    </item>
  </channel>
</rss>

