The SAS Output Delivery System and reporting techniques

Adding a Blank Line in Proc Report Output

Reply
New Contributor
Posts: 4

Adding a Blank Line in Proc Report Output

When producing a table, it is often recommended that you put a blank line every 5 or 10 rows to increase readability.

It is not clear whether you can do this with PROC REPORT. Can you do this in PROC REPORT?

If you can do it, how do you do it?

Any ideas?
SAS Super FREQ
Posts: 8,641

Re: Adding a Blank Line in Proc Report Output

Hi, David:
There are 2 possibilities -- inserting the line as one way of improving readability and improving readability by a second method, such as highlighting every other line in a very faint gray or green color.

If you have a very long report, then the easiest thing to do is to make a dummy variable in your dataset that can act as the signal to insert the blank line. Since you can only use the LINE statement at a breaking point in the report, your dummy variable must be a GROUP or ORDER variable. The following code shows how to address both issues ... using ODS HTML as the destination.
[pre]
** GRP will be the "every 5 signal" -- use a MOD on 6 because when I am on the sixth obs, then I have just finished with #5;
** CNTR will be used for highlighting in the second example, but it is also used for setting GRP;
data class;
set sashelp.class;
retain cntr grp;
if _n_ = 1 then grp = 1;
cntr+1;
if mod(cntr,6) = 0 then do;
** reset CNTR and increment GRP var;
grp + 1;
cntr = 1;
end;
run;

ods listing;
proc print data=class;
title 'what do grp and cntr vars look like';
run;

ods listing close;
ods html file='skipline5.html' style=sasweb;
proc report data=class nowd;
title 'Use GRP var only to skip a line';
column grp name age height;
define grp / group noprint;
define name /display;
define age/ display;
define height/display;
break after grp/;
compute after grp;
line ' ';
endcomp;
run;
ods html close;

ods html file='altbar.html' style=sasweb;
proc report data=class nowd;
title 'Use GRP to skip every 5 and CNTR to change highlight';
column grp cntr name age height;
define grp / group noprint;
define cntr/ display noprint;
define name /display;
define age/ display;
define height/display;
break after grp/;
rbreak after/;
compute after grp;
line ' ';
endcomp;
compute cntr;
if mod(cntr,2) gt 0 then
call define(_ROW_,'STYLE',
'style={background=cxeeeeee}');
endcomp;
run;
ods html close;
[/pre]

I prefer the second example (without the blank line) when I'm reading, but other folks may have different preferences. I find the alternating lines make it easier to follow across the row. Of course, it could just be nostalgia for the greenbar paper we used to use for printing on the mainframe, too!

Good luck!
cynthia
Super User
Posts: 980

Re: Adding a Blank Line in Proc Report Output

Hi Cynthia,

 

Thank you for your response to this questions. I have got a similar scenario today and had to display a blank row after every subject. I followed your approach of using the compute after and it was working, however i am getting two blank rows after every subject in the excel output.

 

compute after grp;
line ' ';
endcomp;

 

 

Could you please let me know the reason for it.  It should have displayed only one blank row.

 

Please advice.

 

Thanks,

Jag

Thanks,
Jag
SAS Super FREQ
Posts: 8,641

Re: Adding a Blank Line in Proc Report Output

Hi:

  Adding your new comment to a very, very old post is not a good idea. I missed your new posting in the middle of all the previous posts.  It would be better to start a new post and just include a link to the older post.

 

  Since you only posted 3 lines of code and did not indicate your destination of interest (how you were getting output to Excel -- ODS HTML, ODS MSOFFICE2K, ODS TAGSETS.EXCELXP, etc) or the rest of your code, it is nearly impossible to make a constructive comment or suggestion.

 

  But if I want to put a blank line after EVERY name in a subset from SASHELP.CLASS for example, I do NOT need a "helper" variable at all. See this example. When I run this example, I only get 1 blank line under every name in my subset.

 

cynthia

 

ods html file='c:\temp\blank.html';

ods tagsets.excelxp file='c:\temp\blank.xml' style=htmlblue;

 

proc report data=sashelp.class(obs=5);

  column name age sex height weight;

  define name / order;

  compute after name;

    line ' ';

  endcomp;

run;

 

ods _all_ close;

Occasional Contributor
Posts: 9

Re: Adding a Blank Line in Proc Report Output

Could you please answer my question? It is posted here: https://communities.sas.com/t5/ODS-and-Base-Reporting/Double-line-at-specific-location-in-proc-repor...

 

Thank you!

N/A
Posts: 0

Re: Adding a Blank Line in Proc Report Output

Hi Cynthia,

Your solutions are very helpful.

As for the 'blank' line, how to put dashed line instead?

Thanks
David
SAS Super FREQ
Posts: 8,641

Re: Adding a Blank Line in Proc Report Output

Hi David:
Well, it would be nice if you could put a dashed line. If your destination of interest was HTML, then you probably can use CSS style selectors to put a double line in. And, even as I type that and you think that this is a possibility, then let me just warn that IF you are taking your files from ODS HTML and/or ODS MSOFFICE2K and/or ODS TAGSETS.EXCELXP and opening the result file with Excel that the CSS method ONLY works in the browser -- not in Excel (and I can't remember about Word).

In SAS 9.2 for RTF, there will be style attributes for top border, bottom border, etc, so you can set different borders for the top of a row vs the bottom of a row. For now, the empty line method or the shading method is what you have to do. (And before a bunch of folks remind me that you could fill the line with bunches of = signs or - symbols -- been there, done that -- it doesn't really look that nice, in my opinion.)

cynthia
Post a Question
Discussion Stats
  • 6 replies
  • 6853 views
  • 0 likes
  • 5 in conversation