<?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: adding up -some- lines in a data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824995#M325841</link>
    <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines delimiter=',';
   input County :$15. Race :$20. Data;
datalines;
Albany,White,3
Albany,Black,2
Albany,Asian,5
Albany,Pacific Islander,3
Allegany,White,1
Allegany,Black,6
Allegany,Asian,2
Allegany,Pacific Islander,4
;

proc format;
value $comb
'Asian','Pacific Islander'='Asian/Pacific Islander';
run;
/* create a new data set*/
proc summary data=have nway;
   class county race;
   format race $comb.;
   var data;
   output out=want (drop=_:) sum=;
run;&lt;BR /&gt;/* some different report tables*/&lt;BR /&gt;&lt;BR /&gt;proc tabulate data=have;&lt;BR /&gt;   class county race;&lt;BR /&gt;   format race $comb.;&lt;BR /&gt;   var data;&lt;BR /&gt;   table county,&lt;BR /&gt;         race*data&lt;BR /&gt;   ;&lt;BR /&gt;   table county*race,&lt;BR /&gt;         data&lt;BR /&gt;   ; &lt;BR /&gt;   table race*(county all='Race total'),&lt;BR /&gt;         data&lt;BR /&gt;   ;&lt;BR /&gt;   table county*(race all='County total') all='Overall total',&lt;BR /&gt;        data&lt;BR /&gt;   ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;This creates a new data set. "Adding up lines" in data set is a poor description.&lt;/P&gt;
&lt;P&gt;A better format would include all of the values but works for your limited example.&lt;/P&gt;
&lt;P&gt;Formats are an extremely powerful tool in SAS. Groups of many types can be created from different ranges of the same variable. I have up to a dozen Age related formats that are used in the Report, Analysis or Graphing steps.&lt;/P&gt;
&lt;P&gt;The groups created by a format are honored by almost every procedure and can reduce coding associated with creating new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2022 18:34:59 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-07-22T18:34:59Z</dc:date>
    <item>
      <title>adding up -some- lines in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824988#M325837</link>
      <description>&lt;P&gt;Hi all. I have a data set like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;County Race Data&lt;BR /&gt;Albany White 3&lt;BR /&gt;Albany Black 2&lt;BR /&gt;Albany Asian 5&lt;BR /&gt;Albany Pacific Islander 3&lt;BR /&gt;Allegany White 1&lt;BR /&gt;Allegany Black 6&lt;BR /&gt;Allegany Asian 2&lt;BR /&gt;Allegany Pacific Islander 4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add together the lines for "Asian" and "Pacific Islander" but leave the rest of the lines as they are. So, the resulting race categories would be White, Black and Asian/Pacific Islander, with the numbers for those last two combined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any simple way to do this?&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;Gene&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 17:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824988#M325837</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-07-22T17:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: adding up -some- lines in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824993#M325840</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31988"&gt;@geneshackman&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would create a format and use it in a PROC SUMMARY step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $race
'Asian','Pacific Islander'='Asian/Pacific Islander';
run;

proc summary data=have nway;
class county race / order=data;
format race $race.;
var data;
output out=want(drop=_:) sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2022 18:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824993#M325840</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-22T18:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: adding up -some- lines in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824995#M325841</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines delimiter=',';
   input County :$15. Race :$20. Data;
datalines;
Albany,White,3
Albany,Black,2
Albany,Asian,5
Albany,Pacific Islander,3
Allegany,White,1
Allegany,Black,6
Allegany,Asian,2
Allegany,Pacific Islander,4
;

proc format;
value $comb
'Asian','Pacific Islander'='Asian/Pacific Islander';
run;
/* create a new data set*/
proc summary data=have nway;
   class county race;
   format race $comb.;
   var data;
   output out=want (drop=_:) sum=;
run;&lt;BR /&gt;/* some different report tables*/&lt;BR /&gt;&lt;BR /&gt;proc tabulate data=have;&lt;BR /&gt;   class county race;&lt;BR /&gt;   format race $comb.;&lt;BR /&gt;   var data;&lt;BR /&gt;   table county,&lt;BR /&gt;         race*data&lt;BR /&gt;   ;&lt;BR /&gt;   table county*race,&lt;BR /&gt;         data&lt;BR /&gt;   ; &lt;BR /&gt;   table race*(county all='Race total'),&lt;BR /&gt;         data&lt;BR /&gt;   ;&lt;BR /&gt;   table county*(race all='County total') all='Overall total',&lt;BR /&gt;        data&lt;BR /&gt;   ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;This creates a new data set. "Adding up lines" in data set is a poor description.&lt;/P&gt;
&lt;P&gt;A better format would include all of the values but works for your limited example.&lt;/P&gt;
&lt;P&gt;Formats are an extremely powerful tool in SAS. Groups of many types can be created from different ranges of the same variable. I have up to a dozen Age related formats that are used in the Report, Analysis or Graphing steps.&lt;/P&gt;
&lt;P&gt;The groups created by a format are honored by almost every procedure and can reduce coding associated with creating new variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 18:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/824995#M325841</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-22T18:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: adding up -some- lines in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/825336#M326000</link>
      <description>This seems to be the way. Thanks.</description>
      <pubDate>Mon, 25 Jul 2022 18:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/adding-up-some-lines-in-a-data-set/m-p/825336#M326000</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-07-25T18:18:57Z</dc:date>
    </item>
  </channel>
</rss>

