<?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 Proc report: Grouping observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668265#M200294</link>
    <description>&lt;P&gt;Hi - is there a way to group observations together, i.e. if fruit is variable and i want to group apple and orange as Group 1 to show in output report?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I got now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of data:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Fruit&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Apple&lt;/P&gt;
&lt;P&gt;Orange&lt;/P&gt;
&lt;P&gt;Grapes&lt;/P&gt;
&lt;P&gt;Banana&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc report data=final;&lt;BR /&gt;columns fruit n;&lt;BR /&gt;define fruit/group;&lt;BR /&gt;define n /'Count'; &lt;BR /&gt;rbreak after / summarize; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jul 2020 06:22:13 GMT</pubDate>
    <dc:creator>ywon111</dc:creator>
    <dc:date>2020-07-10T06:22:13Z</dc:date>
    <item>
      <title>Proc report: Grouping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668265#M200294</link>
      <description>&lt;P&gt;Hi - is there a way to group observations together, i.e. if fruit is variable and i want to group apple and orange as Group 1 to show in output report?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I got now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of data:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Fruit&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Apple&lt;/P&gt;
&lt;P&gt;Orange&lt;/P&gt;
&lt;P&gt;Grapes&lt;/P&gt;
&lt;P&gt;Banana&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc report data=final;&lt;BR /&gt;columns fruit n;&lt;BR /&gt;define fruit/group;&lt;BR /&gt;define n /'Count'; &lt;BR /&gt;rbreak after / summarize; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 06:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668265#M200294</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2020-07-10T06:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report: Grouping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668267#M200296</link>
      <description>&lt;P&gt;I think you would need a column in your final dataset that contains the grouping information you are looking to group by in the proc report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 210px; width: 50px;" border="1" width="50"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;
&lt;P&gt;&lt;STRONG&gt;CATEGORY&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;FRUIT&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;&lt;STRONG&gt;COUNT&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Group 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Apple&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;
&lt;P&gt;10&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Group 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Orange&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Group 2&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Grapes&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Group 2&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Banana&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you could define CATEGORY as a group variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 06:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668267#M200296</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-10T06:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report: Grouping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668385#M200341</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's an example using SASHELP.CLASS. Suppose you want to put the students into 2 categories -- Yes or No -- are they eligible for Driver's Ed based on their age. You can do that with a user defined format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1594391741313.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47053i840D9F0BCD52F553/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1594391741313.png" alt="Cynthia_sas_0-1594391741313.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now the user-defined format is just the beginning. It only defines how the ages get broken up into categories. Now the format needs to be used. This is the output I want to create:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1594391805242.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47054i1CD4B2414FBE29C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1594391805242.png" alt="Cynthia_sas_1-1594391805242.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Notice that I have a sub-category of M and F for the male and female students and I'm getting a count of each gender within each age category. I've also added subtotals of count and a grand total for all students at the bottom of the report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the PROC REPORT code that does everything in one step. Since age is a numeric variable, I wanted to make a helper column to hold the category value and the longer text on the break lines. That was all accomplished in the COMPUTE block for AGECAT, my helper variable:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_2-1594392024862.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47055i61FB0D9834BFEDE3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_2-1594392024862.png" alt="Cynthia_sas_2-1594392024862.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps point you toward one possible solution with PROC REPORT.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 14:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-Grouping-observations/m-p/668385#M200341</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-07-10T14:41:31Z</dc:date>
    </item>
  </channel>
</rss>

