<?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: Transpose proc report and ods to excel in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232489#M14591</link>
    <description>&lt;P&gt;The basic approach would be to change the role of month from a row group variabe to column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly a different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show the code used to generate your current table for more specific suggestions.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Oct 2015 17:44:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-10-30T17:44:46Z</dc:date>
    <item>
      <title>Transpose proc report and ods to excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232477#M14589</link>
      <description>&lt;P&gt;I have a proc report and ods tagsets.excelxp to print out the following to excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;Average&lt;/TD&gt;&lt;TD&gt;Average APR&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1453&lt;/TD&gt;&lt;TD&gt;$215,132,461&lt;/TD&gt;&lt;TD&gt;$148,060.88&lt;/TD&gt;&lt;TD&gt;24.6%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1854&lt;/TD&gt;&lt;TD&gt;$413,651,584&lt;/TD&gt;&lt;TD&gt;$223,113.04&lt;/TD&gt;&lt;TD&gt;31.5%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;2543&lt;/TD&gt;&lt;TD&gt;$568,413,215&lt;/TD&gt;&lt;TD&gt;$223,520.73&lt;/TD&gt;&lt;TD&gt;12.5%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;4863&lt;/TD&gt;&lt;TD&gt;$156,487,435&lt;/TD&gt;&lt;TD&gt;$32,179.20&lt;/TD&gt;&lt;TD&gt;18.5%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&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;Is it possible to print out the transposed result to excel with the formats?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;TD&gt;1453&lt;/TD&gt;&lt;TD&gt;1854&lt;/TD&gt;&lt;TD&gt;2543&lt;/TD&gt;&lt;TD&gt;4863&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;$215,132,461&lt;/TD&gt;&lt;TD&gt;$413,651,584&lt;/TD&gt;&lt;TD&gt;$568,413,215&lt;/TD&gt;&lt;TD&gt;$156,487,435&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Average&lt;/TD&gt;&lt;TD&gt;$148,060.88&lt;/TD&gt;&lt;TD&gt;$223,113.04&lt;/TD&gt;&lt;TD&gt;$223,520.73&lt;/TD&gt;&lt;TD&gt;$32,179.20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Average APR&lt;/TD&gt;&lt;TD&gt;24.6%&lt;/TD&gt;&lt;TD&gt;31.5%&lt;/TD&gt;&lt;TD&gt;12.5%&lt;/TD&gt;&lt;TD&gt;18.5%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Besides, I have thought of the "proc report out =" combined with "proc transpose " &amp;nbsp;,but i have hundreds of rows in real situation so it will be mess, It will be grateful if there is another way to print out the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 16:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232477#M14589</guid>
      <dc:creator>Haha_Lun</dc:creator>
      <dc:date>2015-10-30T16:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose proc report and ods to excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232489#M14591</link>
      <description>&lt;P&gt;The basic approach would be to change the role of month from a row group variabe to column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly a different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show the code used to generate your current table for more specific suggestions.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 17:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232489#M14591</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-30T17:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose proc report and ods to excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232574#M14597</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could try the following...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I restructured your initial data, then used PROC REPORT and the tagattr option to achieve the formatting you were looking for.&amp;nbsp; The output is somewhat rough cut, however, you could make adjustments quite easy and include a PROC FORMAT with a preloadfmt and order=data&amp;nbsp;option in the define statement to order the data as you originally shown (count was first.).&amp;nbsp; I would assume there is a better way to cirmcumnavigate the problem.&amp;nbsp; This seemed to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options source;
data orig (sortedby=month);
	infile datalines dlm='|';
	input month :3.
		  count :8.
		  amount :dollar20.
		  average :dollar20.2
		  average_apr :percent9.1
	;
	length group $ 15 value 8;
	array t{4} $ 15 _temporary_ ('Count','Amount','Average','Average APR');
	array v{*} count amount average average_apr;
	i+1;
		do j=1 to dim(v);
			group=t{j};
			value=v{j};
			output;
			i=0;
		end;
datalines;
5|1453|$215,132,461|$148,060.88|24.6% 
6|1854|$413,651,584|$223,113.04|31.5% 
7|2543|$568,413,215|$223,520.73|12.5% 
8|4863|$156,487,435|$32,179.20|18.5% 
;
run;

%macro spin;
proc report data=orig nowindows missing;
	column group month, value 
%do i=1 %to 4;
		derived_value&amp;amp;i.
%end;
	;
	define group / group;
	define month / across;
	define value / noprint analysis;
%do i=1 %to 4;
	define derived_value&amp;amp;i. / computed;
	compute derived_value&amp;amp;i.;
		derived_value&amp;amp;i.=_c%eval(&amp;amp;i.+1)_;
		if group='Count' then call define(_col_,'style','style={tagattr="format:#####"}');
		else if group='Amount' then call define(_col_,'style','style={tagattr="format:$###,###,###"}');
		else if group='Average' then call define(_col_,'style','style={tagattr="format:$###,###,###.00"}');
		else if group='Average APR' then call define(_col_,'style','style={tagattr="format:0.0%"}');
	endcomp;
%end;

run;

%mend spin;

ods tagsets.excelxp file='&amp;lt;put your path here...\sas_question.xls';

%spin;

ods tagsets.excelxp close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 31 Oct 2015 17:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232574#M14597</guid>
      <dc:creator>kybowma</dc:creator>
      <dc:date>2015-10-31T17:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose proc report and ods to excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232903#M14616</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your suggestions. &amp;nbsp;There is a bit different on the data structure. &amp;nbsp;I have thousands of data by month. &amp;nbsp;Each of them has a total amount, apr and other businese information. &amp;nbsp;I need to sum up the total amount, average out the total amount and calculate the weighted apr as below. &amp;nbsp;In my case, I need to computed like fifty summary columns. &amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand I can use "proc report-&amp;gt;proc transpose-&amp;gt;ods + proc report" to finish it but it seems too mess for fifty columns. &amp;nbsp; I will like&amp;nbsp;to ask if there is any chance to have a shorter way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data orig (sortedby=month);
	infile datalines dlm=',';
	input month :3.
		  count :8.
		  amount :dollar20.
		  apr :percent9.1
	;
datalines;
5,846,153248457,0.284
5,607,61884004,0.1518
6,1154,186453156,0.296
6,700,227198428,0.330592581
7,1265,284657518,0.134
7,1278,283755697,0.115971397
8,2045,68945324,0.148
8,2818,87542111,0.214139999
;
run;

data a_1;
set orig;
weighted_apr = amount*apr;
run;

proc report data = a_1;
columns month count amount weighted_apr avg_amt avg_apr;
define month /group ;
define count/sum;
define amount/sum format=dollar20.;
define weighted_apr / sum noprint;
define avg_amt / computed format=dollar20.2 ;
define avg_apr / computed format=percent9.1 ;
compute avg_apr ;
avg_amt  = amount.sum / count.sum;
avg_apr = weighted_apr.sum/amount.sum;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&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;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 15:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Transpose-proc-report-and-ods-to-excel/m-p/232903#M14616</guid>
      <dc:creator>Haha_Lun</dc:creator>
      <dc:date>2015-11-03T15:55:32Z</dc:date>
    </item>
  </channel>
</rss>

