The SAS Output Delivery System and reporting techniques

Space between columns

Reply
Contributor
Posts: 43

Space between columns

Hi there,

I have problems again with proc report and the rtf outputs. I'm programming the listing of a SAP and I need use the minimum possible space between cells. I can achieve that setting in my template style cellpadding=0.75 for example. With this, on one hand I get reduce properly the space between rows but on the other hand the information between columns is almost stuck.

Does Somebody know if it is possible set the space between columns and rows independtly?

I know the order spacing= inside proc report but it doesn't work when I export the table to rtf.

Thanks!

Juan Vicente.
SAS Super FREQ
Posts: 8,739

Re: Space between columns

Hi, Juan:
You might find this previous forum posting to be useful. It had an example of how to reduce "very wide" reports.
http://support.sas.com/forums/thread.jspa?messageID=414ƞ

One suggestion for your particular needs is to see whether there is a "Narrow" version of the font that you are using for the report and switch to that.

Another style attribute to explore is cellspacing -- depending on what you want to do, cellspacing also affects the amount of space between each cell. Think of cellpadding as being the "white" space around your value in a data cell and cellspacing as being the space around the 4 sides of the data cell itself. Remember to be careful when you specify your value units for cellpadding and cellspacing. For RTF, I believe that your units of measure -- whatever they are -- are translated to TWIPS (twentieths of a printers point) -- because that's what RTF uses. So the number you provide in inches or points or pixels is undergoing some transformation in order to conform with this RTF specification.

Your observation is correct that cellpadding (like cell spacing) affects all 4 edges/areas -- top, bottom, left, and right -- of the cells in a table.

If you do not find a font/cellpadding/cellspacing combination that makes your RTF report look the way you want, then the other thing to explore is whether the indent= style attribute or the leftmargin= style attribute might help indent the text in the cell a bit. But I would not fiddle with those until you had first explored the other options (as they could affect cell value alignment -- possibly making centered values look not centered, etc).

More complicated is exploring whether there's an RTF control string that would affect the table spacing. This is a slightly risky approach, as RTF is very fussy about matching { and } and having the \ctrl-str in the right places. If you don't get the RTF syntax right, you can corrupt the RTF file to the point that Word will not open it.

For either of these last 2 approaches, you'd have to turn to Tech Support for help, although there were some forum postings on RTF control strings that you might be able to find by searching the forum.

cynthia

** Updated to add this information:
Also, there are some "preproduction" features in ODS that you can try. They include style attributes for setting widths and borders on each of the 4 edges of the cell separately, as described here:
http://support.sas.com/rnd/base/topics/odsrtf/rtf901.html
and they were specifically designed for RTF -- so they're worth a try.
Contributor
Posts: 43

Re: Space between columns

Thanks Cynthia! As always I'm very impressed about your knowledge Smiley Happy

I was about get crazy when I figured out that I was using the instructions that you recommended me in a wrong place. I was using it in table style properties instead of the cell style.

When I wrote

replace cell from Output /
leftmargin=2pt; /* see the complete code below*/

it worked properly but it had the problem that it adds space to each column, even to the first one and it is not desirable.

I find out the style(column) options in proc report and I used it with leftmargin statement. Finally I reduced the code with a macro and now it is similar to use the option spacing= in proc report.


proc template;
define style Styles.aa;
parent = Styles.RTF;
replace Table from Output /
frame = hsides
rules = groups
just = left
cellpadding = 0pt
cellspacing = 0.75pt
borderwidth = 0.75pt
;
/*
replace cell from Output /
leftmargin=2pt;
*/

end;
run;

proc format;
value $sex 'M'='MALE'
'F'='FEMALE';
run;

%macro s(spaces);
style(column)=[leftmargin=&spaces.pt]
%mend;

ods rtf file='c:\temp\style.rtf' style=Styles.aa;

proc report data=sashelp.class nowd headline headskip nocenter missing;
column NAME SEX AGE HEIGHT WEIGHT;
define NAME / order order=data left;
define SEX / order order=data %s(2) left f=$sex.;
define AGE / display left %s(2);
define HEIGHT / display left %s(2) 'H' ;
define WEIGHT / display left %s(2) 'W' ;
run;
ods rtf close;
SAS Super FREQ
Posts: 8,739

Re: Space between columns

Juan:
Very good! Glad it works for you now.
cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 1183 views
  • 0 likes
  • 2 in conversation