BookmarkSubscribeRSS Feed
SASUserMD
Obsidian | Level 7

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.

 

6 REPLIES 6
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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. 

SASUserMD
Obsidian | Level 7

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;
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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?

SASUserMD
Obsidian | Level 7

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;
ballardw
Super User

@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.

Cynthia_sas
SAS Super FREQ

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 835 views
  • 0 likes
  • 4 in conversation