This looks buggish to me, but I can't tell if the bug is in PROC REPORT and ODS EXCEL, or the XLSX engine. And I'm out of time playing this morning...
By eye the two Excel files created by length $199 and length $200 look the same, but clearly they are not exactly the same because SAS is reading them in differently, and truncating the data when it reads in the Excel file that was created from a $200 variable. So there must be some difference in the Excel files. If I had more time, my next step would be to unzip the xlsx files and compare the xml files to see where the difference is. Or maybe someone better than me with Excel can spot the difference just lookin at attributes in excel.
Here is my test coded that replicates the problem.
Interestingly, if the ODS EXCEL block if I change from PROC REPORT to PROC PRINT, everything works fine. That's odd, and another clue worth following up on...
%let workpath = %sysfunc(pathname(work));
%put workpath=&workpath.;
data x199;
length x $199 ;
x = '-1'; output;
x = '-10'; output;
x = '-100'; output;
x = '-10'; output;
x = '-1'; output;
run;
data x200;
length x $200 ;
x = '-1'; output;
x = '-10'; output;
x = '-100'; output;
x = '-10'; output;
x = '-1'; output;
run;
ods listing close ;
ods excel file="&workpath\x199.xlsx";
ods excel options (sheet_name="XXX");
proc report data=x199; format _all_ ;run;
ods excel close;
ods listing ;
ods listing close ;
ods excel file="&workpath\x200.xlsx";
ods excel options (sheet_name="XXX");
proc report data=x200; format _all_ ;run;
ods excel close;
ods listing ;
libname x199 xlsx "&workpath\x199.xlsx";
libname x200 xlsx "&workpath\x200.xlsx";
data _null_ ;
set x199.xxx ;
format _all_ ;
put "length=$199 " x= ;
run ;
data _null_ ;
set x200.xxx ;
format _all_ ;
put "length=$200 " x= ;
run ;
Returns:
1286 data _null_ ;
1287 set x199.xxx ;
1288 format _all_ ;
1289 put "length=$199 " x= ;
1290 run ;
length=$199 x=-1
length=$199 x=-10
length=$199 x=-100
length=$199 x=-10
length=$199 x=-1
NOTE: The import data set has 5 observations and 1 variables.
NOTE: There were 5 observations read from the data set X199.xxx.
1291
1292 data _null_ ;
1293 set x200.xxx ;
1294 format _all_ ;
1295 put "length=$200 " x= ;
1296 run ;
length=$200 x=-1
length=$200 x=-1
length=$200 x=-1
length=$200 x=-1
length=$200 x=-1
NOTE: The import data set has 5 observations and 1 variables.
NOTE: There were 5 observations read from the data set X200.xxx.
... View more