The SAS Output Delivery System and reporting techniques

print column label vertically?

Reply
N/A
Posts: 0

print column label vertically?

Hi,

i'm told of a new user requirement that column labels should be optionally printed vertically or horizontally. i don't think Proc Template, Proc Report can do vertical print of column label. then i found out about ExcelXP tagset & SGF papers "generating custom excel spreadsheets using ods" & "the beginners guide to ods markup: don't panic!"

is it possible? say combining ExcelXP tagset to send data to Excel then use OLE automation to drive Excel to print?

but what we need is create output to MS Word RTF and not directly send to printer. should i tell my boss this new requirement is not possible? Thanks for your advice,

Hsiwei
SAS Super FREQ
Posts: 8,864

Re: print column label vertically?

Posted in reply to deleted_user
Hi:
Without venturing into the world of CSS or Microsoft-specific style properties (which in some instances will let you rotate the headers). You CAN rotate the headers using code like this:

[pre]
ods pdf file='c:\temp\class_v.pdf';
ods rtf file='c:\temp\class_v.rtf';
ods msoffice2k(1) file='c:\temp\class_v1.html' style=sasweb;
ods msoffice2k(2) file='c:\temp\class_v2.xls' style=sasweb;

proc print data=sashelp.class heading=v;
var name age height;
run;

ods escapechar = '~';

proc report data=sashelp.class nowd;
column name age height;
define name / order 'N~nA~nM~nE';
define age / display 'A~nG~nE';
define height/ display 'H~nE~nI~nG~nH~nT';
run;

proc means data=sashelp.class min mean max;
class age;
var height;
label age = 'Age'
height= '~nH~nE~nI~nG~nH~nT';
run;

ods _all_ close;
[/pre]

Proc PRINT has the HEADING=V option which does work for PDF, RTF and HTML (looks better to me in the other destinations than when you open the HTML file with Excel). For Proc REPORT (or the label in PROC MEANS and other procs), you can use the ODS ESCAPECHAR sequence
[pre] ESCAPECHAR + n [/pre]
which, as shown above is ~n (tilde is the ESCAPECHAR + n) to insert a "line feed" after every character in the header.

There -is- an MSO-ROTATE style property which you might be able to send into an HTML file using the HTMLSTYLE attribute or the TAGATTR attribute, but Microsoft honors the style property differently (I can't exactly remember without testing) -- but the rotation might work in Word, not in Excel and possibly in IE. You'd have to check with Tech Support for sure about using MSO-ROTATE.

cynthia
N/A
Posts: 0

Re: print column label vertically?

Posted in reply to Cynthia_sas
Thanks Cynthia!

I was using data _null_; put _ODS_; to write to RTF.

Will experiment with
ESCAPECHAR + n

Cheers,
Super Contributor
Posts: 291

Re: print column label vertically?

Posted in reply to deleted_user
While it may be possible to write a label vertically, from a readability point of view, it's NOT desirable. I would make every effort to keep all titles, labels & notes horizontal. It's usually a more effective use of the screen / page real estate as well.
SAS Super FREQ
Posts: 8,864

Re: print column label vertically?

Hi:
I agree with you. For one thing, putting the header vertically, assumes that you are always going to have a "fully-sighted" person reading the report. It would be horrible for someone with limited vision using screen reading software to have to deal with a vertical header like this. Using vertical headers may save space on the page, but it is not really "user-friendly" or reading software friendly.

Just because something is "possible" doesn't mean it's a best practice. I find that a lot of "requirements" involve needlessly jumping through cosmetic hoops. Requirements like this for vertical headers should be re-examined. Granted, the requirement was to be able to generate the headers vertically or horizontally. Why bother with vertical headers at all?

However, the original question that ended the post was: "should i tell my boss this new requirement is not possible? " So, it's possible. But, I agree with Bill -- in my opinion, I don't think it's the best idea to implement for the reasons stated above.

cynthia
Contributor
Posts: 47

Re: print column label vertically?

Posted in reply to Cynthia_sas
It's possible to rotate column headers in RTF by doing a little post-processing routine which essentially replaces the RTF markup language command for horizontal headers with vertical headers. Wayne Hester helped with this a while back and I have the code for it if desired. I agree that the look is not optimal - however, I was asked to do it for some reports and it does work. It is a useful technique when you have more columns than will fit on a page with horizontal labels. The code is also available in a SUGI 30 paper "PROC TABULATE and RTF: the Perfect Fit for Complex Tables."

By the way if you are outputting to Excel you can accomplish the same by passing through a command via in-line style formats (or build a template with the command.) (There's a paper by Vince DelGobbo on this.)

Good luck!
Ask a Question
Discussion stats
  • 5 replies
  • 598 views
  • 0 likes
  • 4 in conversation