<?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: Complex PROC Report (Cumulative totals; Multiple across variables; Grand total columns) in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282771#M16293</link>
    <description>&lt;P&gt;Please post the code anyway. Sometimes it turns out to br pretty close and you're only missing one or two bits. As a minimum it gives folks variable names and such.&lt;/P&gt;
&lt;P&gt;It would also be ideal to provide a small data set that shows the basic behavior of your data providing basic challenges (2 nests at any level). If you can provide that as a datastep then tested code may be provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;has an example of code to turn your dataset into a data step.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2016 21:51:47 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-07-07T21:51:47Z</dc:date>
    <item>
      <title>Complex PROC Report (Cumulative totals; Multiple across variables; Grand total columns)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282756#M16292</link>
      <description>&lt;P&gt;&lt;IMG title="Data2.png" alt="Data2.png" src="https://communities.sas.com/t5/image/serverpage/image-id/3954iE5FF56D723449BF6/image-size/original?v=v2&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got a dataset that looks like the one above, and I need an output report that looks like so:&lt;/P&gt;&lt;P&gt;&lt;IMG title="SampTable.png" alt="SampTable.png" src="https://communities.sas.com/t5/image/serverpage/image-id/3955i5BD51DDB5651D570/image-size/original?v=v2&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Number of workdays" is Lag_Workdays&amp;nbsp;used as a classification variable.&lt;/P&gt;&lt;P&gt;"Delayed/Non-delayed" is Priority used as a classification variable&lt;/P&gt;&lt;P&gt;"Total Consultations" is a set of total columns (i.e., Delayed + Non-Delayed)&lt;/P&gt;&lt;P&gt;"2010/2011" is Intake_Year used as a classification variable (the original dataset has 6 years of data, but I've truncated the output report to show only these two years for this example.&amp;nbsp; In the final report I want all 6 years.)&lt;/P&gt;&lt;P&gt;"N" is N (i.e., number of records within those classifications)&lt;/P&gt;&lt;P&gt;"%" is percent N&lt;/P&gt;&lt;P&gt;"cumtot" and "cumpct" are cumulative total and cumulative percent respectively&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously PROC Freq creates these types of frequency tables naturally, but due to the number of nested classifications it seemed like I needed something with a little more power.&amp;nbsp; (I know that I can run Proc Freq and create output tables, then splice those tables back together to create the final report, but I was hoping for something a little more sophisticated.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I turned to PROC Tabulate, but proc tab can't do cumulative freqs and percents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I found a paper on how to do cumulative freqs and percents with PROC Report, but that procedure is not my particular forte, so I quickly got stumped.&amp;nbsp; I'd be happy to share the code that I've developed so far, but it's probably a gross bastardization of PROC Report that would embarass any proper programmer. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 18:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282756#M16292</guid>
      <dc:creator>TashaChapman14</dc:creator>
      <dc:date>2016-07-07T18:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Complex PROC Report (Cumulative totals; Multiple across variables; Grand total columns)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282771#M16293</link>
      <description>&lt;P&gt;Please post the code anyway. Sometimes it turns out to br pretty close and you're only missing one or two bits. As a minimum it gives folks variable names and such.&lt;/P&gt;
&lt;P&gt;It would also be ideal to provide a small data set that shows the basic behavior of your data providing basic challenges (2 nests at any level). If you can provide that as a datastep then tested code may be provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;has an example of code to turn your dataset into a data step.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 21:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282771#M16293</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-07T21:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Complex PROC Report (Cumulative totals; Multiple across variables; Grand total columns)</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282785#M16296</link>
      <description>&lt;P&gt;Ok, here's my bastardized code...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=consults nowd;
format priority $del.;
where status not in ('07' '08' '09') and intake_date le '31dec2015'd;
column  lag_workdays intake_year=all,(tk=acount tk=apct ytd cumpct) priority,intake_year,(tk=count tk=pct) ;
define all / across 'Total Consultations';
define acount / analysis n format=comma8. 'N';
define apct / analysis pctn format=percent8.2 '%';
define priority / across ' ';
define intake_year / across ' ';
define lag_workdays / group 'Number of workdays' missing;
define count / analysis n format=comma8. 'N';
define pct / analysis pctn format=percent8.2 '%';
define ytd / computed;
define cumpct / computed;
compute before;
	total+acount;
	cumtot=0;
endcomp;
compute ytd;
	cumtot+acount;
	ytd=cumtot;
endcomp;
compute cumpct;
	cumpct=ytd/total;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So far I can get the basic structure of the report to work. &amp;nbsp;The piece that isn't working is the compute blocks. &amp;nbsp;It's all coming out as&amp;nbsp;missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm guessing that a significant part of my probably is how I'm using the TK field to calculate the N and PCTN columns. &amp;nbsp;It looks like I'm doing that wrong, but I'm not sure what the correct way is to create those columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relatedly, the compute block portion&amp;nbsp;says that "acount" is uninitialized. &amp;nbsp;When I try to change the reference to something like "tk.N" it gives me an error that says that using tk.N is inappropriate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's the paper that I found that gave me the basic structure for calculating the cumulative columns:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi27/p120-27.pdf&amp;nbsp;" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p120-27.pdf&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As shown in the example above, I'd like the cumulative totals to show up for all sections of the report, not just within the "Total Consultations" portion, but I didn't get that far...&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 20:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Complex-PROC-Report-Cumulative-totals-Multiple-across-variables/m-p/282785#M16296</guid>
      <dc:creator>TashaChapman14</dc:creator>
      <dc:date>2016-07-07T20:20:54Z</dc:date>
    </item>
  </channel>
</rss>

