HI. I am trying to use a combination of PROC EXPORT and PROC REPORT.
I have 1 SAS dataset and I'd like to export that to Excel into multiple worksheets based on customer ID (one worksheet per customer). I also want to add the same title to each worksheet. Seems I cannot add titles using PROC EXPORT and I cannot figure out how to breakout my dataset into multiple worksheets using PROC REPORT.
Here is the code for exporting to multiple worksheets:
/*WORKS FOR EXPORTING WITH FORMAT AND 3 TITLE ROWS*/
%let rundate = %SYSFUNC(today(),yymmddn8.);
/* export report */
ods escapechar="~";
ods excel file="c:\users\my_name\documents\test..xlsx" options(sheet_name="Sheet1");
ods text="~{style[color=green fontstyle=italic] BANKRUPTCY CASE NO.";
ods text="~{style[color=green fontstyle=italic] FILED";
proc report data=work.SUMMARY/*(obs=5) */spanrows
style(report)={pretext=" "};
run;
ods excel close;
How can I combine the two? 1 SAS dataset exported to 1 Excel workbook with 1 worksheet per customer with a title.
Thanks.
Use BY statement and ODS EXCEL option
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.