BookmarkSubscribeRSS Feed
JuanVte
Calcite | Level 5
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.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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.
JuanVte
Calcite | Level 5
Thanks Cynthia! As always I'm very impressed about your knowledge 🙂

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;
Cynthia_sas
SAS Super FREQ
Juan:
Very good! Glad it works for you now.
cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 5947 views
  • 0 likes
  • 2 in conversation