<?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 tabulate to create multiple reports by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636505#M189108</link>
    <description>&lt;LI-SPOILER&gt;Hello&lt;BR /&gt;&lt;BR /&gt;I have a raw data with loans information in year 2020 from 01.01.2020&amp;nbsp; until 31.03.2020.&lt;BR /&gt;There are following fields in the row table:&lt;BR /&gt;Customer_ID&lt;BR /&gt;Date_of_loan&lt;BR /&gt;Sum_loan&lt;BR /&gt;sector&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Then I need to add 2 new calculated fields:&lt;BR /&gt;day_loan&amp;nbsp; is the day from field date_of_loan (for example for date 13FEB2020 the day is 13)&lt;BR /&gt;month_loan is the month from field date_of_loan(for example for date 13Feb2020 the month is 2)&lt;BR /&gt;&lt;BR /&gt;The task is to create for each sector a summary report that will have the following fields:&lt;BR /&gt;day_loan&lt;BR /&gt;Sum_loan in month 1 (Jan)&lt;BR /&gt;Sum loan in month 2 (Feb)&lt;BR /&gt;Sum loan in month 3 (March)&lt;BR /&gt;&lt;BR /&gt;I have 2 questions:&lt;BR /&gt;1- Is there a way to use proc tabulate to create multiple tables ?(Here I create a macro var and write manually all sectors that appear in the raw table but I want to find a more clever way )&lt;BR /&gt;2-Is there a way to export the multiple summary tables to one excel sheet with side by side structure?&lt;BR /&gt;&lt;BR /&gt;I cannot copy paste from SAS so I need to type the code manually here (apologize)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector=Cars+Real_Estate+Shops+Factories;
%let k=4;

%macro tabulate;
%Do  j=1  %TO  &amp;amp;k.;
%let sector=%SCAN(&amp;amp;vector.,&amp;amp;j.,+);
Title;
Title "&amp;amp;sector.";
proc tabulate data=Rawtbl (Where=(sector=&amp;amp;sector.));
class  day_loan  month_loan;
VAR sum_loan;
table day_loan='',sum_loan=''*(Sum='sum of loans in $')*month_loan='month'/box='day';
Run;
%end;
%mend;
%tabulate;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;</description>
    <pubDate>Wed, 01 Apr 2020 11:47:05 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-04-01T11:47:05Z</dc:date>
    <item>
      <title>proc tabulate to create multiple reports by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636505#M189108</link>
      <description>&lt;LI-SPOILER&gt;Hello&lt;BR /&gt;&lt;BR /&gt;I have a raw data with loans information in year 2020 from 01.01.2020&amp;nbsp; until 31.03.2020.&lt;BR /&gt;There are following fields in the row table:&lt;BR /&gt;Customer_ID&lt;BR /&gt;Date_of_loan&lt;BR /&gt;Sum_loan&lt;BR /&gt;sector&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Then I need to add 2 new calculated fields:&lt;BR /&gt;day_loan&amp;nbsp; is the day from field date_of_loan (for example for date 13FEB2020 the day is 13)&lt;BR /&gt;month_loan is the month from field date_of_loan(for example for date 13Feb2020 the month is 2)&lt;BR /&gt;&lt;BR /&gt;The task is to create for each sector a summary report that will have the following fields:&lt;BR /&gt;day_loan&lt;BR /&gt;Sum_loan in month 1 (Jan)&lt;BR /&gt;Sum loan in month 2 (Feb)&lt;BR /&gt;Sum loan in month 3 (March)&lt;BR /&gt;&lt;BR /&gt;I have 2 questions:&lt;BR /&gt;1- Is there a way to use proc tabulate to create multiple tables ?(Here I create a macro var and write manually all sectors that appear in the raw table but I want to find a more clever way )&lt;BR /&gt;2-Is there a way to export the multiple summary tables to one excel sheet with side by side structure?&lt;BR /&gt;&lt;BR /&gt;I cannot copy paste from SAS so I need to type the code manually here (apologize)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Vector=Cars+Real_Estate+Shops+Factories;
%let k=4;

%macro tabulate;
%Do  j=1  %TO  &amp;amp;k.;
%let sector=%SCAN(&amp;amp;vector.,&amp;amp;j.,+);
Title;
Title "&amp;amp;sector.";
proc tabulate data=Rawtbl (Where=(sector=&amp;amp;sector.));
class  day_loan  month_loan;
VAR sum_loan;
table day_loan='',sum_loan=''*(Sum='sum of loans in $')*month_loan='month'/box='day';
Run;
%end;
%mend;
%tabulate;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 01 Apr 2020 11:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636505#M189108</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-04-01T11:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate to create multiple reports by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636509#M189111</link>
      <description>&lt;P&gt;You can combine by and class to produce several reports in one run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=sashep.cars
  out=cars
;
by origin;
run;

proc tabulate data=cars;
class make;
by origin;
var msrp;
table make*msrp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 12:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636509#M189111</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-01T12:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate to create multiple reports by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636596#M189137</link>
      <description>&lt;P&gt;Or use one or more Class variables to create a "Page" level, then you get one table per level of the Page expression:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.cars;
	class make;
	class origin;
	var msrp;
	table origin,      /* &amp;lt;= Page*/
	      make*msrp,   /* &amp;lt;= Row */
	      sum            /* &amp;lt;= Column */
	;
run;&lt;/PRE&gt;
&lt;P&gt;And Proc Tabulate will allow multiple TABLE statements in a single proc call.&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.cars;
	class make;
	class origin;
	class type;
	var msrp;
	table origin,      /* &amp;lt;= Page*/
	      make*msrp,   /* &amp;lt;= Row */
	      sum          /* &amp;lt;= Column */
	;
	table origin,      /* &amp;lt;= Page*/
	      make*msrp,   /* &amp;lt;= Row */
	      type *mean         /* &amp;lt;= Column */
	;

run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 15:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-to-create-multiple-reports-by-group/m-p/636596#M189137</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-01T15:58:31Z</dc:date>
    </item>
  </channel>
</rss>

