DATA Step, Macro, Functions and more

vertical text alignment in proc tabulate

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

vertical text alignment in proc tabulate


Below is my proc tabulate code.  I'd like the first variable in the table, the page variable 'cohort', to print with vertical alignment to save space.   Can someone tell me how to do it?  I've searched far and wide and have not found an answer yet.   

Bill

 

****************   code  ********************

proc tabulate data =&input f=4.0 S=[just=c cellwidth=75]; 

var Col1;
class cohort criterion instrument /ORDER=DATA ;
class _name_ ;
table cohort*instrument*criterion all={label='Total' s=[just=R background=lightblue]}*{s=[just=C background=lightblue]} ,(_name_='Level' ALL)*Col1=" "*(sum="N"*(f=cnum.) ROWPCTSUM="%"*f=mypct. ) /box=_PAGE_; 
BY instrument NOTSORTED; 
run;

 


Accepted Solutions
Solution
‎09-15-2016 05:57 PM
Regular Contributor
Posts: 175

Re: vertical text alignment in proc tabulate

This paper suggests using VJUST. From the documentation, looks like you can specify VJUST=TOP, BOTTOM, or MIDDLE.

View solution in original post


All Replies
Solution
‎09-15-2016 05:57 PM
Regular Contributor
Posts: 175

Re: vertical text alignment in proc tabulate

This paper suggests using VJUST. From the documentation, looks like you can specify VJUST=TOP, BOTTOM, or MIDDLE.

Occasional Contributor
Posts: 15

Re: vertical text alignment in proc tabulate

Posted in reply to paulkaefer

I actually looked at that paper already and never noticed that line.   It was right in front of my face!   Thanks!

Occasional Contributor
Posts: 15

Re: vertical text alignment in proc tabulate

Posted in reply to paulkaefer

Update after actually trying the suggestion.  Specifying Vjust does't work the way I want.  It locates the horizontal text at the top, center or bottom of the box.  I want to rotate the text so the text is printed vertically.     I'm still stuck!    Any other ideas?

 

Text should be like this:

 

A

n

s

w

e

r

 

and not like this.   Answer

Regular Contributor
Posts: 175

Re: vertical text alignment in proc tabulate

Ah, so you want rotated text. Try this solution.

Occasional Contributor
Posts: 15

Re: vertical text alignment in proc tabulate

Posted in reply to paulkaefer

Thanks.  Can't get that to work, it gives an error message, maybe because I'm using this for a PDF output and that article is for an Excel worksheet?   

 

I just created the style using this code from the article:

------------------   code from the suggested article to create a rotated text style -----------------------

proc template;
define style styles.mystyle;
parent=styles.default;
style vertical_header from header /
tagattr = 'rotate:90'
;
end;
run;

------------------   end of code from the suggested article to create a rotated text style -----------------------

 

 

Then I inserted that style where I want it, in the values for the cohort column.   Gives an error.   Not clear that proc tabulate will allow me to use styles that I create, or did I skip a step??

 

------------------------   my proc tabulate code to print a pdf file  --------------------------------

proc tabulate data =&input f=4.0 S=[just=c cellwidth=70]; 
var Col1;
class cohort criterion instrument /ORDER=DATA ;
class _name_ ;
classlev cohort /style=[vertical_header]; 
table cohort*instrument*criterion all={label='Total' s=[just=R background=lightblue]}*{s=[just=C background=lightblue]} ,(_name_='Level' ALL)*Col1=" "*(sum="N"*(f=cnum.) ROWPCTSUM="%"*f=mypct. ) /box=_PAGE_; 
BY instrument NOTSORTED; 
run;

 

Regular Contributor
Posts: 175

Re: vertical text alignment in proc tabulate

Try including it in the PROC TABULATE call instead:

 

proc tabulate data=tabhow style=[vertical_header];

via this paper.

Occasional Contributor
Posts: 15

Re: vertical text alignment in proc tabulate

Posted in reply to paulkaefer
Can't make that work either. I don't think it would do what I want even if
it did work, it would apply to the entire table. I only want the values for
one of the three class columns to have vertical text. I want all the
headers to be normal and the other two class columns to have normal headers
and values. This is done in proc tabulate by using a classlev statement
and assigning the formatting there. Maybe this just can't be done.



##- Please type your reply above this line. Simple formatting, no
attachments. -##
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 577 views
  • 2 likes
  • 2 in conversation