<?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: Creating a table with Proc Report Sas 9.4 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953764#M372563</link>
    <description>&lt;P&gt;Reorganising your data would make your report a lot easier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input @1 Type $2. @5 Month monyy7. @12 Amount 6.;
format month monyy7.;
Year = year(month);
datalines;
A   Jul2022 512284
A   Jul2023 511247
A   Jul2024 537950
A   Aug2022 467846
A   Aug2023 494399
A   Aug2024 494519
A   Sep2022 456741
A   Sep2023 477914
A   Sep2024 585883		
A   Oct2022	441665
A   Oct2023 473957
A   Oct2024 554541		
A   Nov2022	352226	
A   Nov2023 342704
A   Nov2024 720150		
A   Dec2022	584206
A   Dec2023 451450
A   Dec2024 366774		
B   Jul2022	32906
B   Jul2023 32906
B   Jul2024 92393	
B   Aug2022	35597
B   Aug2023 38010
B   Aug2024 40322
B   Sep2022 36720
B   Sep2023 42826
B   Sep2024 36455
B   Oct2022	51224
B   Oct2023 43689
B   Oct2024 46408
B   Nov2022 35151
B   Nov2023 52637
B   Nov2024 44017
C   Jul2022	346722
C   Jul2023 308021
C   Jul2024 293111			
C   Aug2022 328668
C   Aug2023 304660
C   Aug2024 270731		
C   Sep2022	683099
C   Sep2023 576012
C   Sep2024 527964		
C   Oct2022	992834
C   Oct2023 811538
C   Oct2024 751706		
C   Nov2022	910997
C   Nov2023 818528	
C   Nov2024 748760		
C   Dec2022	724850
C   Dec2023 552243
C   Dec2024 749465		
;
run;

proc report data=have nowd;
column Type year Amount, Month ;
define Type/ group style=header;
define Year / group;
define Month / across style=header order=internal format = monname3.;
define Amount / ' ' sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASKiwi_0-1734388695926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103061iAF110389AC372804/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASKiwi_0-1734388695926.png" alt="SASKiwi_0-1734388695926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2024 22:38:26 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2024-12-16T22:38:26Z</dc:date>
    <item>
      <title>Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953731#M372559</link>
      <description>&lt;P&gt;I am trying to create a table like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 522px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103041i626F532417C9B3A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;With this data but haven't been able to get the right results.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Type$	Month$ Y22 Y23 Y24	;

datalines;

A	July	512284	511247	537950			
A	Aug	  	467846	494399	494519		
A	Sep		456741	477914	585883		
A	Oct		441665	473957	554541		
A	Nov		352226	342704	720150		
A	Dec		584206	451450	366774		
B	July	32906	32906	92393	
B	Aug		35597	38010	40322
B	Sep		36720	42826	36455
B	Oct		51224	43689	46408
B	Nov		35151	52637	44017
C	July	346722	308021	293111			
C	Aug		328668	304660	270731		
C	Sep		683099	576012	527964		
C	Oct		992834	811538	751706		
C	Nov		910997	818528	748760		
C	Dec		724850	552243	749465		
 
;
run;


proc report data=have nowd;
column Type Y22 Y23 Y24,Month;
define Type/ group style=header;
define Month/ across style=header order=internal;
define Y22/ group style=header ;
define Y23/ group style=header ;
define Y24/ group style=header ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have spent a lot of time playing around with the existing proc report but haven't had any luck.&amp;nbsp; Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 19:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953731#M372559</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2024-12-16T19:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953733#M372560</link>
      <description>&lt;P&gt;Which parts are you having problems with?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that the repeated column headers are going to have problems as that is not a normal request from Proc report though an Break Before with a computed block might do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But sort orders for character values as dates are problematic as well. You will need a Variable to hold values like "Y22" as Proc Report doesn't do vertically stacked variables.&lt;/P&gt;
&lt;P&gt;Is the repeated header critical? If not, perhaps this would be sufficient and doesn't require rebuilding your data set:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data= have;
   class type;
   class month/order=data;
   var Y22 Y23 Y24;
   table type*(Y22 Y23 Y24)*sum=''*f=best8.,
         month
         /misstext=' '
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2024 20:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953733#M372560</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-12-16T20:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953750#M372561</link>
      <description>&lt;P&gt;You could reshape your data to make them more suitable for the report you're after.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Type$	Month$ Y22 Y23 Y24;
	datalines;
A July 512284 511247 537950
A Aug    467846 494399 494519
A Sep  456741 477914 585883
A Oct  441665 473957 554541
A Nov  352226 342704 720150
A Dec  584206 451450 366774
B July 32906 32906 92393
B Aug  35597 38010 40322
B Sep  36720 42826 36455
B Oct  51224 43689 46408
B Nov  35151 52637 44017
C July 346722 308021 293111
C Aug  328668 304660 270731
C Sep  683099 576012 527964
C Oct  992834 811538 751706
C Nov  910997 818528 748760
C Dec  724850 552243 749465  		
;
run;

data prep;
	set have;
	array vars {*} y22 y23 y24;
	do _i=1 to dim(vars);
		var_name=vname(vars[_i]);
		var_val =vars[_i];
		output;
	end;
	drop _i y22 y23 y24;
run;

%let sv_missing=%sysfunc(getoption(missing,keyword));
options missing=' ';
proc report data=prep nowd;
	column Type var_name var_val, Month;
	define Type/ group style=header;
	define Month/ across style=header order=data;
	define var_name/ group style=header ' ';
	define var_val/ display sum ' ';
run;
options &amp;amp;sv_missing;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1734387807848.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103048iEAA21D4F0187098B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1734387807848.png" alt="Patrick_0-1734387807848.png" /&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>Mon, 16 Dec 2024 22:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953750#M372561</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-12-16T22:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953759#M372562</link>
      <description>&lt;P&gt;Your main issue: having data in structure, see Maxim 19.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=long;
by type month notsorted;
var y:;
run;

proc report data=long;
column type _name_ col1,month;
define type / "" group;
define _name_ / "" group;
define col1 / "" analysis;
define month / "" across order=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS avoid having tabs in code, particularly in DATALINES.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 22:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953759#M372562</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-12-16T22:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953764#M372563</link>
      <description>&lt;P&gt;Reorganising your data would make your report a lot easier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input @1 Type $2. @5 Month monyy7. @12 Amount 6.;
format month monyy7.;
Year = year(month);
datalines;
A   Jul2022 512284
A   Jul2023 511247
A   Jul2024 537950
A   Aug2022 467846
A   Aug2023 494399
A   Aug2024 494519
A   Sep2022 456741
A   Sep2023 477914
A   Sep2024 585883		
A   Oct2022	441665
A   Oct2023 473957
A   Oct2024 554541		
A   Nov2022	352226	
A   Nov2023 342704
A   Nov2024 720150		
A   Dec2022	584206
A   Dec2023 451450
A   Dec2024 366774		
B   Jul2022	32906
B   Jul2023 32906
B   Jul2024 92393	
B   Aug2022	35597
B   Aug2023 38010
B   Aug2024 40322
B   Sep2022 36720
B   Sep2023 42826
B   Sep2024 36455
B   Oct2022	51224
B   Oct2023 43689
B   Oct2024 46408
B   Nov2022 35151
B   Nov2023 52637
B   Nov2024 44017
C   Jul2022	346722
C   Jul2023 308021
C   Jul2024 293111			
C   Aug2022 328668
C   Aug2023 304660
C   Aug2024 270731		
C   Sep2022	683099
C   Sep2023 576012
C   Sep2024 527964		
C   Oct2022	992834
C   Oct2023 811538
C   Oct2024 751706		
C   Nov2022	910997
C   Nov2023 818528	
C   Nov2024 748760		
C   Dec2022	724850
C   Dec2023 552243
C   Dec2024 749465		
;
run;

proc report data=have nowd;
column Type year Amount, Month ;
define Type/ group style=header;
define Year / group;
define Month / across style=header order=internal format = monname3.;
define Amount / ' ' sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASKiwi_0-1734388695926.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103061iAF110389AC372804/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASKiwi_0-1734388695926.png" alt="SASKiwi_0-1734388695926.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 22:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953764#M372563</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-12-16T22:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953776#M372568</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[EDIT]&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It is time to show the power of PROC SQL + PROC REPORT skill.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Type$	Month$ Y22 Y23 Y24;
	datalines;
A July 512284 511247 537950
A Aug    467846 494399 494519
A Sep  456741 477914 585883
A Oct  441665 473957 554541
A Nov  352226 342704 720150
A Dec  584206 451450 366774
B July 32906 32906 92393
B Aug  35597 38010 40322
B Sep  36720 42826 36455
B Oct  51224 43689 46408
B Nov  35151 52637 44017
C July 346722 308021 293111
C Aug  328668 304660 270731
C Sep  683099 576012 527964
C Oct  992834 811538 751706
C Nov  910997 818528 748760
C Dec  724850 552243 749465  		
;
run;
proc format;
invalue mon(upcase)
'JAN'=1
'FEB'=2
'MAR'=3
'APR'=4
'MAY'=5
'JUN'=6
'JULY'=7
'AUG'=8
'SEP'=9
'OCT'=10
'NOV'=11
'DEC'=12
;
run;
proc sql;
create table temp as
select 1 as id1,type,month,'Y22' as year,put(sum(Y22),best32. -l) as value length=400
 from have
  group by type,month
union all
select 1 as id1,type,month,'Y23' as year,put(sum(Y23),best32. -l) as value
 from have
  group by type,month
union all
select 1 as id1,type,month,'Y24' as year,put(sum(Y24),best32. -l) as value
 from have
  group by type,month

union all
select 0 as id1,type,month,'09'x,month
 from (select distinct type from have),(select distinct month from have)

order by type,id1,year,input(month,mon.)
;
quit;

proc transpose data=temp out=report(drop=_name_) prefix=_;
by type id1 year;
var value;
id month;
run;

proc report data=report nowd;
columns ('Type' type) id1 year ('Month' _:) ;
define type/order ' ' style=header;
define id1/display noprint;
define year/display ' ' style=header;
define _:/display ' ' ;
compute id1;
if id1=0 then call define(_row_,'style','style=header');
endcomp;
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1734485003551.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103130i63E1EE3304D1251E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1734485003551.png" alt="Ksharp_0-1734485003551.png" /&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;</description>
      <pubDate>Wed, 18 Dec 2024 07:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953776#M372568</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-18T07:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with Proc Report Sas 9.4</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953783#M372572</link>
      <description>&lt;P&gt;To simulate the screenshot style, try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=tran;
  by type notsorted;
  var month y:;
run;

%let styles=backgroundcolor=cxedf2f9 font_weight=bold color=cx112277;
proc report data=tran style(header column)={just=center};
  column ("Type" type) _name_ ("Month" col1-col6);
  define type       /style(column)={&amp;amp;styles.} order order=data "";
  define _name_     /style(column)={&amp;amp;styles.} "";
  define col1-col6  /"";
  compute _name_;
    if _name_="Month" then do;
      _name_="";
      call define(_row_,"style","style={&amp;amp;styles.}");
    end;
  endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="whymath_0-1734407684660.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103067i7F5AB74F5D9D5649/image-size/medium?v=v2&amp;amp;px=400" role="button" title="whymath_0-1734407684660.png" alt="whymath_0-1734407684660.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 03:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-with-Proc-Report-Sas-9-4/m-p/953783#M372572</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2024-12-17T03:54:59Z</dc:date>
    </item>
  </channel>
</rss>

