Hello,
I use several MACROS in the RTF environment. Within the MACROS I often use PROC TABULATE to build a certain structure. Strangely enough, invisible lines are inserted in the RTF after the MACRO call. How can that be?
Here is a short example (creates 6 emtpy lines after the first table):
ods rtf startpage=no;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
%MACRO TEST;
%DO i=1 %TO 5;
ods select none;
proc tabulate data=sashelp.class;
ods output Table=Table1;
class sex age;
tables sex age, n;
run;
ods select all;
%END;
%MEND;
%TEST;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
ods rtf close;
Thanks for your help.
the do loop is creating you blank lines
@SASUserMDhas %DO i=1 %TO 5;
change it to %DO i=1 %TO 12; and you will have 12 blank lines in your output.
Yes, but that is still the responsibility of the PROC TABULATE.
Same problem without loop:
ods rtf startpage=no;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
ods select none;
proc tabulate data=sashelp.class;
ods output Table=Table1;
class sex age;
tables sex age, n;
run;
proc tabulate data=sashelp.class;
ods output Table=Table1;
class sex age;
tables sex age, n;
run;
proc tabulate data=sashelp.class;
ods output Table=Table1;
class sex age;
tables sex age, n;
run;
ods select all;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
ods rtf close;
when I replace ods select none;
with ods select all;
I get 1 blank line using your new code Does it happen to be the select none statement?
It must be a problem of the PROC TABULATE. If you use PROC FREQ and noprint there are no empty lines. But there is no noprint option in PROC TABULATE.
PROC FREQ example:
ods rtf startpage=no;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
ods select none;
proc freq data=sashelp.class noprint;
ods output OneWayFreqs=Table1;
tables sex;
run;
proc freq data=sashelp.class noprint;
ods output OneWayFreqs=Table1;
tables sex;
run;
proc freq data=sashelp.class noprint;
ods output OneWayFreqs=Table1;
tables sex;
run;
ods select all;
proc tabulate data=sashelp.class;
class sex age;
tables sex age, n;
run;
ods rtf close;
@SASUserMD wrote:
It must be a problem of the PROC TABULATE. If you use PROC FREQ and noprint there are no empty lines. But there is no noprint option in PROC TABULATE.
PROC FREQ example:
ods rtf startpage=no; proc tabulate data=sashelp.class; class sex age; tables sex age, n; run; ods select none; proc freq data=sashelp.class noprint; ods output OneWayFreqs=Table1; tables sex; run; proc freq data=sashelp.class noprint; ods output OneWayFreqs=Table1; tables sex; run; proc freq data=sashelp.class noprint; ods output OneWayFreqs=Table1; tables sex; run; ods select all; proc tabulate data=sashelp.class; class sex age; tables sex age, n; run; ods rtf close;
I have to question why if you do not actually want tabular output it is included at all in the ODS part.
Since things like ODS RTF , PDF and HTML are to generate output to be read by people it seems that better practice is to do all preparation prior to the ODS / ODS CLOSE "sandwich" and then only have the procedure generating displayed output.
You might find that ODS TAGSETS.RTF and the PARSKIP option can reduce empty lines.
There are other issues involved as well. For instance the tables generated by Proc Freq have table templates you can modify with proc template, Tabulate does not (at least not yet).
If you need tabulate to build data sets you also might try the OUT= option on the proc statement instead of ODS OUTPUT.
Hi:
I think if you show/hide the symbols when you open the RTF file in Word, you'll be able to see whether what is inserted into the RTF file is a section break, a paragraph or a page break. Since you have STARTPAGE=NO, the page break is turned off, but you might still be inserting a section break between procedures.
It's not actually TABULATE, per se, that is inserting empty "lines". Every procedure, by default, starts on a new page --no matter what the procedure is. When you turn STARTPAGE=NO, then you are turning off the page break, but I believe that white space is still inserted.
You might want to open a track with Tech Support to see whether changing the PARSKIP element (as shown here https://support.sas.com/resources/papers/proceedings11/246-2011.pdf on pages 4-5) would help you in this scenario.
Cynthia
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.