I have a macro that inserts pngs into an rtf file using PROC REPORT and rtf field code. It is producing the following error:
ERROR: At least one column width is wider than LINESIZE.
This error occurs even though I have verified that the rtf field code is not wide enough to cause this issue and the linesize is set to max. I was able to track down the root cause as the OPTIONS NOCENTER included in our standard autoexec. When this option is commented out, the macro runs without any problem (we have a bunch of different options specified, shown below, but the only one that eliminates the error is nocenter)
options ps=max /* USE NUMBER NEAR 50 IF PRINTING .lst */ ls=max /* USE NUMBER NEAR 120 IF PRINTING .lst */ nocenter /* LEFT JUSTIFY ALL OUTPUT */ nonumber /* DO NOT USE PAGE NUMBERS IN PROC OUTPUT */ nodate /* DO NOT USE DATE IN PROC OUTPUT */ compress=yes /* COMPRESSES DATASET TO SAVE SPACE ON SERVER */ fmtsearch=( specform library )/* SEARCH ORDER FOR FORMATS IN PROGRAMS */ ;
We do have a workaround--since the output is intended to go to an rtf, users put "ods listing close;" before calling the macro and then "ods listing;" afterward to restart sending output to the list. However, it would be ideal not to have to do that. Does anyone have an explanation as to why NOCENTER is causing the LINESIZE error to occur and/or if there's a way to stop that from happening?
If you want PROC REPORT not to complain when the column width is too long for the linesize then specify shorter column widths in the DEFINE statements.
Example:
data test;
set sashelp.class(obs=3);
length all $200;
all=catx('|',of _all_);
run;
proc report data=test;
run;
proc report data=test;
define all / width=20 flow ;
run;
7 proc report data=test; NOTE: Writing HTML Body file: sashtml.htm 8 run; ERROR: The width of all is not between 1 and 78. Adjust the column width or line size. NOTE: This affects LISTING output. NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 3 observations read from the data set WORK.TEST. NOTE: PROCEDURE REPORT used (Total process time): real time 0.64 seconds cpu time 0.14 seconds 9 proc report data=test; 10 define all / width=20 flow ; 11 run; NOTE: There were 3 observations read from the data set WORK.TEST. NOTE: PROCEDURE REPORT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
The ERROR message is specific to the Listing destination, so turning that destination off using either:
ods listing close;
or
ods _all_ close;
before the ODS RTF statement is the most logical solution for eliminating the Error. Just commenting out NOCENTER does not necessarily mean that is it set to the default. I would like to see
proc options option=center;
run;
before the ODS RTF statement to see what it is set to. If you have additional questions or problems, please send the log as an attachment so that we can see the complete code and messages you are getting.
Since you are running a macro. And a macro that already generates steps (PROC REPORT) you can add the commands to shut down listing to your macro.
You could just close the listing and open it again.
....
ods listing close;
proc report .....
ods listing ;
...
But that would open the listing if it wasn't open before.
Instead why not use ODS SELECT instead and only generate the commands when the listing destination is active.
data _null_;
set sashelp.vdest;
where destination='LISTING';
call execute('ods listing select none;');
run;
proc report ....
...
data _null_;
set sashelp.vdest;
where destination='LISTING';
call execute('ods listing select all;');
run;
If you want PROC REPORT not to complain when the column width is too long for the linesize then specify shorter column widths in the DEFINE statements.
Example:
data test;
set sashelp.class(obs=3);
length all $200;
all=catx('|',of _all_);
run;
proc report data=test;
run;
proc report data=test;
define all / width=20 flow ;
run;
7 proc report data=test; NOTE: Writing HTML Body file: sashtml.htm 8 run; ERROR: The width of all is not between 1 and 78. Adjust the column width or line size. NOTE: This affects LISTING output. NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 3 observations read from the data set WORK.TEST. NOTE: PROCEDURE REPORT used (Total process time): real time 0.64 seconds cpu time 0.14 seconds 9 proc report data=test; 10 define all / width=20 flow ; 11 run; NOTE: There were 3 observations read from the data set WORK.TEST. NOTE: PROCEDURE REPORT used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
Thank you. I was able to use this to arrive at my solution.
This was very confusing because the linesize set for the listing is max (256), so everything inside the macro was limited to this (lots of length checks) and the test case I was using only had a length of about 100 characters. Everything works perfectly fine when OPTIONS NOCENTER is not specified (everything prints to the lst without any problems) but I get the LINESIZE error when OPTIONS NOCENTER is specified. Using the syntax you suggested, I started at width = 256 and still got the error, but once I got to width = 254, the error disappeared.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.