ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lisagsmi1
Calcite | Level 5

How can I send a PROC PRINT that has BY Groups to ODS EXCEL and have it stay on one sheet?

 

 

I need to create an Excel report that looks like a PROC PRINT with By Groups, and a Sum. 

 

Input SAS dataset looks like this: 

 

Region               State          Count

------------------------------------------------

EASTERN          GA             5

EASTERN          FL              4

EASTERN          AL              3

WESTERN         CA             7

WESTERN         OR             8

WESTERN         WA             9

 

Spreadsheet needs to look like this:

 

Region               State          Count

------------------------------------------------

EASTERN          GA             5

                           FL              4

                           AL              3

WESTERN         CA             7

                           OR             8

                           WA             9

--------------------------------------------

Grand Total                          36

 

I need the BY and ID in the following code to get the region to look right, but using the BY causes multiple sheets. 

 

(SAS Release 9.04.01M2P072314)

 

 

ods excel file="&OUTPUT_PATH.\&OUTPUT_FILE._&yyyymmdd..xlsx"
options ( /* Display options */
	sheet_name="OUTPUT_RPT"
	absolute_column_width='40,6,7'
	embedded_titles='on')
	;
run;

proc print data=cons_rpt noobs  sumlabel label;
	var
		Region
		State      
		Count 		; 
	by Region;
	id Region;
	label Region='Grand Total'
	;
	sum count;

run;
ods excel close;

run;

 

 

(Please don't make me use Tagsets.ExcelXP)

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Try the SHEET_INTERVAL option in your options list, set it to none. 

 

 

Sheet_Interval='none'

 

http://support.sas.com/documentation/cdl/en/odsug/69832/HTML/default/viewer.htm#p09n5pw9ol0897n1qe04...

View solution in original post

4 REPLIES 4
Reeza
Super User

Try the SHEET_INTERVAL option in your options list, set it to none. 

 

 

Sheet_Interval='none'

 

http://support.sas.com/documentation/cdl/en/odsug/69832/HTML/default/viewer.htm#p09n5pw9ol0897n1qe04...

lisagsmi1
Calcite | Level 5
Thanks - that worked to get me onto one sheet. Now I just have to get the sums in the right place.
Thanks!
Reeza
Super User

You should consider PROC tabulate. 

Cynthia_sas
SAS Super FREQ
Or PROC REPORT.... but still PROC PRINT should be able to get the totals in the right place for you.

cynthia

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 4 replies
  • 6624 views
  • 0 likes
  • 3 in conversation