<?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 do I collapse/combine identical observations using a Quantity variable? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282699#M16288</link>
    <description>&lt;P&gt;Ok. When I saw EG I assumed you were using GUI.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should summarize and precalculate things before proc report. It will make you code cleaner and if you ever need edits you'll thank yourself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im going to move your post to reporting forum for a better response.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2016 14:45:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-07-07T14:45:03Z</dc:date>
    <item>
      <title>How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282681#M16284</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**NOVICE CODER...PLEASE EXPLAIN ANSWERS AS THOROUGHLY AS POSSIBLE, THANK YOU!!!!**&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a report generated through PROC REPORT with 7 variables. &amp;nbsp; I would like to create a 'Quantity" column that will combine observations if the value of every variable is the same and tell me how many there were.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example the first&amp;nbsp;report below would be converted into the second one (the variables are PRESIDENT SECESSION PARTY QUANTITY):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;George Washington &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; None &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;George Washington &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;None &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;John Adams &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Federalist &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Thomas Jefferson &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Thomas Jefferson &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Thomas Jefferson &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;James Madison &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;George Washington &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;None &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;John Adams &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Federalist &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Thomas Jefferson &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;James Madison &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dem-Rep &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NOTE: I'm using SAS EG&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 14:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282681#M16284</guid>
      <dc:creator>jwinkle</dc:creator>
      <dc:date>2016-07-07T14:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282685#M16285</link>
      <description>&lt;P&gt;You have two option, either a summarize task or Query builder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a summary task select option to create an output table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a query builder add all fields to select, add the ones that need to be identical to group by clause, and a computed column that adds up quantity.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 14:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282685#M16285</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-07T14:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282689#M16286</link>
      <description>&lt;P&gt;I have been trying Query Builder, but I cannot figure out how to use it in PROC REPORT and still retain all of the many format changes I have applied. &amp;nbsp; Here is an example of the code and I just need to combine identical observations as the last task (I know this code is scrappy and inefficient, but it works hehe):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC report data=hedge_report;&lt;BR /&gt;columns (default_swap_ref_entity Issuer_id facility_id&lt;BR /&gt;long_description) ("Swap Option Information" mature_date crf fix_rate1 n);&lt;BR /&gt;define default_swap_ref_entity / order;&lt;BR /&gt;define Issuer_ID / order;&lt;BR /&gt;define Facility_ID / order format=facID.;&lt;BR /&gt;define long_description / order;&lt;BR /&gt;define mature_date / display;&lt;BR /&gt;define CRF / display format=dollar.;&lt;BR /&gt;define fix_rate1 / display format=percent.2;&lt;BR /&gt;compute fix_rate1;&lt;BR /&gt;do fix_rate1=(fix_rate1/100);&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute mature_date;&lt;BR /&gt;if (today()-mature_date)&amp;lt;0&lt;BR /&gt;then do;&lt;BR /&gt;call define("_C5_","style","STYLE={background=cx5bff5b font=('serif,Gill Sans MT',2)}");&lt;BR /&gt;call define("mature_date","format","active.");&lt;BR /&gt;end;&lt;BR /&gt;else if (today()-mature_date)&amp;gt;=730&lt;BR /&gt;then do;&lt;BR /&gt;call define("_C5_","style","STYLE={background=cxff5b5b font=('serif,Times',2, bold)}");&lt;BR /&gt;call define("mature_date","format","expiry1plus.");&lt;BR /&gt;end;&lt;BR /&gt;else if (today()-mature_date)&amp;gt;=365 and (today()-mature_date)&amp;lt;730&lt;BR /&gt;then do;&lt;BR /&gt;call define("_C5_","style","STYLE={background=cxff855b font=('serif,Times',2, bold)}");&lt;BR /&gt;call define("mature_date","format","expiry1plus.");&lt;BR /&gt;end;&lt;BR /&gt;else if (today()-mature_date)&amp;gt;=0 and (today()-mature_date)&amp;lt;365&lt;BR /&gt;then do;&lt;BR /&gt;call define("_C5_","style","STYLE={background=cxffff5b font=('serif,Times',2, bold)}");&lt;BR /&gt;call define("mature_date","format","expiry01a.");&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;compute crf;&lt;BR /&gt;&lt;BR /&gt;if 0&amp;lt;=CRF&amp;lt;1000000 then do;&lt;BR /&gt;call define("_C6_","style","STYLE={color=GREEN fontweight=bold}");&lt;BR /&gt;end;&lt;BR /&gt;else if abs(CRF)&amp;gt;=1000000 then do;&lt;BR /&gt;call define("_C6_","style","STYLE={color=GREEN fontweight=bold}");&lt;BR /&gt;call define("crf","format","ProfLoss.");&lt;BR /&gt;end;&lt;BR /&gt;else if CRF&amp;lt;0 then&lt;BR /&gt;call define("_C6_","style","STYLE={color=RED fontweight=bold}");&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 14:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282689#M16286</guid>
      <dc:creator>jwinkle</dc:creator>
      <dc:date>2016-07-07T14:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282690#M16287</link>
      <description>&lt;P&gt;This is a job for PROC SUMMARY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc summary data = in missing nway;
  class president secession party;
  var quantity;
  output out = reduced( drop = _type_ _freq_ ) sum=;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jul 2016 14:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282690#M16287</guid>
      <dc:creator>sh0e</dc:creator>
      <dc:date>2016-07-07T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282699#M16288</link>
      <description>&lt;P&gt;Ok. When I saw EG I assumed you were using GUI.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you should summarize and precalculate things before proc report. It will make you code cleaner and if you ever need edits you'll thank yourself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im going to move your post to reporting forum for a better response.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 14:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282699#M16288</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-07T14:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282706#M16290</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; This is possible with PROC REPORT without using any other procedure. If this is what you want:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3948i5CF6DC284873E501/image-size/original?v=v2&amp;amp;px=-1" alt="report_group.png" title="report_group.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then here's the code - -showing how to move from DISPLAY usage to GROUP usage to get the QUANTITY column to summarize;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prez;
  length president $50 party $20;
  infile datalines dlm=',' dsd;
  input president $ succession party $ quantity;
datalines;
"George Washington" , 1 , None ,1
"George Washington" , 1 , None ,1
"John Adams", 2 , Federalist,1
"Thomas Jefferson", 3 , Dem-Rep,1
"Thomas Jefferson", 3 , Dem-Rep,1
"Thomas Jefferson", 3 , Dem-Rep,1
"James Madison", 4 , Dem-Rep,1
;
run;

ods html;
proc report data=prez;
title '1) show all data';
  column president succession party quantity;
  define president / display;
  define succession / display;
  define  party / display;
  define quantity / sum;
  rbreak after / summarize;
run;


proc report data=prez;
title '2) use ORDER for some variables';
  column succession president party quantity;
  define succession / order;
  define president / order;
  define  party / display;
  define quantity / sum;
  break after succession / summarize;
  rbreak after / summarize;
run;

proc report data=prez;
title '3) use GROUP for to collapse and summarize';
  column succession president party quantity;
  define succession / group;
  define president / group;
  define  party / group;
  define quantity / sum;
  rbreak after / summarize;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 15:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282706#M16290</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-07-07T15:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I collapse/combine identical observations using a Quantity variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282716#M16291</link>
      <description>&lt;P&gt;Thanks so much!! I got the observations collapsed, but the problem is that when some variables were summed, the formats I applied in a "call define" statement do not work. &amp;nbsp;I cannot figure out how to apply formats when a variable is defined as "sum" or "mean" at the beginning a proc report-- from what I can tell, my user formats are only working on "display" variables.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 15:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-do-I-collapse-combine-identical-observations-using-a/m-p/282716#M16291</guid>
      <dc:creator>jwinkle</dc:creator>
      <dc:date>2016-07-07T15:41:53Z</dc:date>
    </item>
  </channel>
</rss>

