@Tecla1 wrote:
Tnks for your kindly replay.
If a certain condition is met (finding "ADDEBITI" or "POLIZZE" in a list of table name – `%if %sysfunc(find(&nome, ADDEBITI, i)) > 0 %then %do;`), I need to export the table to the same Excel file but to the "ADDEBITI" or "POLIZZE" sheet.
That does not help much since it is not clear where the list of table names is.
But it seems to me if you want to set the name of the SHEET in the XLSX workbook then you should either put it into a macro variable.
ods excel options(sheet_name="&sheetname");
You could generate different sheet names based on some test you want to do. So perhaps something like:
%let sheetname=default_name;
%if %sysfunc(findw(&out,addebiti,%str( ),i)) %then %do;
%let sheetname=ADDEBITI;
%end;
ods excel options(sheet_name="&sheetname");
Make sure to open and close the workbook only once.
ods excel file="myfile.xslx";
%mymacro(sheetname=ADDEBITI);
%mymacro(sheetname=SomethingElse);
ods excel close;
... View more