BookmarkSubscribeRSS Feed
david2010
Calcite | Level 5
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?
6 REPLIES 6
Cynthia_sas
SAS Super FREQ
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
Jagadishkatam
Amethyst | Level 16

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
Cynthia_sas
SAS Super FREQ

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;

deleted_user
Not applicable
Hi Cynthia,

Your solutions are very helpful.

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

Thanks
David
Cynthia_sas
SAS Super FREQ
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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 32827 views
  • 0 likes
  • 5 in conversation