<?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 aggregate two rows (observations) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781257#M31746</link>
    <description>&lt;P&gt;Define a format, use proc summary (code is untested):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format:
  value $categoryfmt
    "unknown", "Other" = "Unknown/Other"
  ;
run;

proc summary data=have nway;
  class category zip_code active;
  var revenue;
  output out=result(drop= _:) sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 19 Nov 2021 14:20:48 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-11-19T14:20:48Z</dc:date>
    <item>
      <title>How to aggregate two rows (observations)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781253#M31744</link>
      <description>&lt;P&gt;Hello, I am working with a data set that is a report about users.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The relevant columns are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Category&lt;/LI&gt;&lt;LI&gt;Zip Code&lt;/LI&gt;&lt;LI&gt;Active&lt;/LI&gt;&lt;LI&gt;Revenue&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;An example of this data is&lt;/P&gt;&lt;PRE&gt;category | zip code | active | revenue

- "unknown" | 12345 | true | 900

- "Other" | 12345 | true | 1000&lt;/PRE&gt;&lt;P&gt;Because of the sources of this data, I want to combine "unknown" and "other" so the report accounts for all the unknown categories. I would like to combine this and aggregate where appropriate so that the result looks like:&lt;/P&gt;&lt;PRE&gt;category | zip code | active | revenue

- "Unknown\Other" | 12345 | true | 1900&lt;/PRE&gt;&lt;P&gt;How would I do this and bonus points if I can do this without creating a new table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781253#M31744</guid>
      <dc:creator>heyyou1</dc:creator>
      <dc:date>2021-11-19T14:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate two rows (observations)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781255#M31745</link>
      <description>&lt;P&gt;Is this problem a table with only two rows, or is it a bigger table with many rows? If it is a bigger table with many rows, what are the rules for combining ... do we combine everything, or by zip code, or by active, or something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the "aggregate" that you mention is really just a sum of the values under revenue? Or did you want somethign else done with revenue?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781255#M31745</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-19T14:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate two rows (observations)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781257#M31746</link>
      <description>&lt;P&gt;Define a format, use proc summary (code is untested):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format:
  value $categoryfmt
    "unknown", "Other" = "Unknown/Other"
  ;
run;

proc summary data=have nway;
  class category zip_code active;
  var revenue;
  output out=result(drop= _:) sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Nov 2021 14:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781257#M31746</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-19T14:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to aggregate two rows (observations)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781278#M31750</link>
      <description>&lt;P&gt;Groups created by a format such as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; suggests would be honored by report procedures such as Proc Report or Tabulate, almost all the analysis procedures and most will work for graphing procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The nice thing about using a Format instead of altering data is that a different format for a procedure can create different groupings based on single variables.. No actual change to the data set needed. This can be a significant time savings if working with largish data sets as the time needed to add new variables can get noticeable. Not to mention having to constantly add variables for new uses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-aggregate-two-rows-observations/m-p/781278#M31750</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-19T15:16:54Z</dc:date>
    </item>
  </channel>
</rss>

