The full code extract was on the original post - included now for reference. In my adapted version of this code the only difference is the fact I am using 'ods tagsets.excelbase' instead of 'ods excel' from the original post. /* 1) proc contents to recover the length of each variables */
proc contents data = table_you_want_export
out = other_name (keep = varnum length) noprint ;
run ;
/* sorting by varnum to have the same order that the table you want export */
proc sort data = other_name ;
by varnum ;
run ;
/* creating a macro variable containing these lengths separated by a comma */
proc sql noprint ;
select length into : length_var separated by ','
from other_name ;
quit ;
/* EXPORT */
ods excel file="path\name_output.xlsx"
options(
flow = "header, data"
absolute_column_width = "&length_var"
absolute_row_height = "20px"
);
Proc print data = table_you_want_export noobs ;
run ;
ods excel close ; The value of the macro variable resolves to: 83 %put &length_var.; SYMBOLGEN: Macro variable LENGTH_VAR resolves to 8,11,14,125,8,8,8,8,8,11,125,14,14,14 8,11,14,125,8,8,8,8,8,11,125,14,14,14 The first value in the macro variable is 8 and the proc print is then applying this length to all columns. Thanks
... View more