<?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 For members of a character column give sum from numerical column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289709#M59846</link>
    <description>&lt;P&gt;Suppose one has the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i_x	        N
_22606_0	20
_20404_6	3
_21001_0	3
_21301_4	14
_21605_0	14
_22501_0	10
_22602_6	10
_21105_1	1
_20706_0	16
_21603_0	4
_22201_4	4
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The desire is to get a total sum of N for each of the individual character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would be the easiest way to do that in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Aug 2016 04:57:40 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2016-08-05T04:57:40Z</dc:date>
    <item>
      <title>For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289709#M59846</link>
      <description>&lt;P&gt;Suppose one has the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i_x	        N
_22606_0	20
_20404_6	3
_21001_0	3
_21301_4	14
_21605_0	14
_22501_0	10
_22602_6	10
_21105_1	1
_20706_0	16
_21603_0	4
_22201_4	4
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The desire is to get a total sum of N for each of the individual character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What would be the easiest way to do that in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 04:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289709#M59846</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-08-05T04:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289713#M59849</link>
      <description>&lt;P&gt;but your char's are distinct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
  Infile Datalines DELIMITER='09'x;
  Input  i_x $ N;
  Datalines;
_22606_0	20
_20404_6	3
_21001_0	3
_21301_4	14
_21605_0	14
_22501_0	10
_22602_6	10
_21105_1	1
_20706_0	16
_21603_0	4
_22201_4	4
;

Proc Means Data=Have NoPrint NWay;
  By Notsorted i_x;
  Var N;
  Output Out=Have_Sum (Drop=_:) Sum=;
Run;

Proc SQL;
  Create Table Have_Sum_SQL As Select i_x,Sum(N) As N From Have Group By i_x;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Aug 2016 05:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289713#M59849</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-08-05T05:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289724#M59853</link>
      <description>&lt;P&gt;Terrific.&amp;nbsp; Been scratching my head trying to get Proc Tabulate to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Three quick follow-ups. Please briefly explain what the following were used for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NWay&lt;BR /&gt;( Drop=_: )&lt;BR /&gt;Sum=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 06:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289724#M59853</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-08-05T06:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289748#M59859</link>
      <description>&lt;P&gt;Makes sense now.&amp;nbsp; Thanks so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My final code on this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=nicholas.n_slope_means__7 ;
by i_x;
run;

proc means data=nicholas.n_slope_means__7
noprint
order=freq
maxdec=0
;
by i_x;
var n;

output out=nicholas.means_summary03
(drop=_:)
sum=
n=
min=
p10=
p20=
p30=
median=
p70=
p80=
p90=
max=
/ autoname
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 07:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289748#M59859</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-08-05T07:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289819#M59880</link>
      <description>&lt;P&gt;You don't say whether you want a report or a dataset for the output.&lt;/P&gt;
&lt;P&gt;Here is what I would consider the easiest:&lt;/P&gt;
&lt;P&gt;This is a shorter dataset with some value of your i_x with different n to demonstrate. If you need a dataset you could use the out=option on the tables statement in proc freq.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
  Infile Datalines ;
  Input  i_x $ N;
  Datalines;
_22606_0	20
_22606_0	12
_20404_6	3
_20404_6	27
_21001_0	3
_21301_4	14
;
run;

proc freq data=have;
   weight n;
   tables i_x;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Proc Summary or means could sum the N values as well&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
   class i_x;
   var N;
   output out=want(drop= _:) sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Aug 2016 15:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/289819#M59880</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-05T15:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: For members of a character column give sum from numerical column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/290375#M60081</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;SPAN&gt;ballardw, for contributing another solution. &amp;nbsp;Works perfectly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 05:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/For-members-of-a-character-column-give-sum-from-numerical-column/m-p/290375#M60081</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2016-08-09T05:17:44Z</dc:date>
    </item>
  </channel>
</rss>

