1. Add an ODS EXCEL statement to create the Excel file
2. In the loop use an ODS EXCEL statement to specify the formatting options you want and the specific sheet name.
3. Use PROC PRINT/REPORT to export your data
That should be all.
If your datasets are all the same format with variables and such, you could stack them and use BY group processing so each tab is created automatically and no loops are needed but I have no idea what your reports are supposed to look like or what your data looks like.
The process is sketched out below, I have not tested this code and it's likely buggy but should give you the idea to get started.
%LET VALRPRTS = TMSHT_VAL_1,TMSHT_VAL_2,TMSHT_VAL_3,TMSHT_VAL_4,TMSHT_VAL_5,TMSHT_VAL_6,TMSHT_VAL_7;
%MACRO VALIDATION_REPORTS;
ods excel file='path to xlsx file' options(list options that will apply to all sheets here) style=meadow;
*You can also specify your style here;
%DO I=1 %TO %SYSFUNC(COUNTW(%BQUOTE(&VALRPRTS),%STR(,)));
%LET NXTREPRT = %SCAN(%BQUOTE(&VALRPRTS),&I);
/* EXPORT THE RESULTS TO THE SAS GLOBAL DIRECTORY FOLDER */
ods excel options(sheet_interval='now' sheet_name = "&nxtreprt.");
*add options;
PROC print data=&nxtreprt.;
.....
run;
%END;
ods excel close;
%MEND VALIDATION_REPORTS;
... View more