BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I want to export multiple summary tables into one XLSX (EXCEL) file into one Sheet.

I want that the tables will be below each other with a few rows distance between them.

I also want that the columns titles will be with grey background.

IT might happend that need to adjust the columns width in order that we can see it well in Excel and in order that it will look nice.

What is the recommended way to do it please and please show the code , thanks 

 

Title 'Table1: One Dimensional Table'
proc tabulate data=sashelp.baseball;
   class Team;
   tables Team;
quit;


Title 'Table2: One Dimensional Table'
proc tabulate data=sashelp.baseball;
   class Team;
   var nHome;
   tables Team, nHome;
quit;


Title 'Table3: One Dimensional Table'
proc tabulate data=sashelp.baseball;
   class Team League;
   var nHome;
   tables League, Team, nHome;
quit;


Title 'Table4: Three Dimensional Table';
 proc tabulate data=sashelp.baseball;
   class Team League;
   var nHome;
   tables League, Team, nHome;
quit;

TITLE ' Listing of Top 5 Rows of SASHELP.SHOES';
proc sql outobs=5;
 select * from sashelp.shoes;
 quit;

Title ' Summary Sales by Region';
proc means data=sashelp.shoes sum;
 class region;
 var sales;
 run;


data weight2;                      
input IDnumber $ Week1 Week16; 
WeightLoss2=Week1-Week16;     
datalines;       
2477 195  163
2431 220  198
2456 173  155
2412 135  116
;                            

proc print data=weight2;      
run;  


data investment;   
   begin='01JAN1990'd;
   end='31DEC2009'd;
   do year=year(begin) to year(end);   
      Capital+2000 + .07*(Capital+2000);
      output;    
   end;
   put 'The number of DATA step iterations is '_n_; 
run;


proc print data=investment;    
format Capital dollar12.2;  
run;

2 REPLIES 2
Tom
Super User Tom
Super User

Just check the documentation on ODS EXCEL destination.

Make sure to include semi-colons to end your TITLE statements.

ods excel file='c:\downloads\one_sheet.xlsx'
  options (embedded_titles='ON' sheet_interval='NONE' sheet_name='REPORT')
; 
Title 'Table1: One Dimensional Table';
proc tabulate data=sashelp.baseball;
   class Team;
   tables Team;
quit;


Title 'Table2: One Dimensional Table';
proc tabulate data=sashelp.baseball;
   class Team;
   var nHome;
   tables Team, nHome;
quit;

ods excel close;

image.png

ballardw
Super User

The documentation for the TITLE statement shows  the options for setting color height font background color text angles and such.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p10gcmrmf83iaxn1ilrx4pra969n.ht...

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2517 views
  • 4 likes
  • 3 in conversation