First step is eliminate the code generation so we can see what code you are trying to run more clearly.
For example you posted this SQL step that appears to be trying to put code into a macro variable.
*MACRO 1;
proc sql noprint;
select distinct
cat("DATA I1_",&month.,"_",compress(&COLUMN.,,'kad'),"; set &TABLE.(where=(&COLUMN.='", &COLUMN.,"'));run;
proc export data=I1_",&month.,"_", &COLUMN.,"
outfile='&out_path.","ST_", &column.,"_", &fecha., "_S_M7_",&month.,"'
dbms=xlsx replace;sheet='SHEET 1';run;
;run")length=500 into :allsteps separated by ';'
from &TABLE.
quit;
Let's see if we can figure out what code it is you are trying to create with that.
Looks a lot like this might be it:
data I1_MONTH_COLUMN-VALUE;
set TABLE (where=(COLUMN="COLUMN-VALUE"));
run;
proc export data=I1_MONTH_COLUMN
outfile="OUT_PATH/ST_COLUMN_FECHA_S_M7_MONTH"
dbms=xlsx
replace
;
sheet='SHEET 1';
run;
Where OUT_PATH, MONTH, FECHA, TABLE and COLUMN are actually being replaced by macro variable values, except in a few places where you are using the actual value of the variable that named by the value of the COLUMN macro variable.
There does not appear to be any need to make dataset. Why not just add the dataset option to the PROC EXPORT call?
Now you mentioned wanting to combine the multiple spreadsheets you are generating. What do you think that should look like? Do you want to write all of the values of COLUMN to the same XLSX workbook, but just into separate sheets? Or perhaps all of the sheets for that value of COLUMN into the same XLSX workbook but with different sheets for each value of MONTH? Or perhaps each value of FECHA?
... View more