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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.