The SAS Output Delivery System and reporting techniques

vjust usage in a region

Accepted Solution Solved
Reply
Regular Contributor
Posts: 179
Accepted Solution

vjust usage in a region

Hi,

 

Am trying to figure out how to vertically center a title in a region and am missing something.  Sample code:

 

ods PDF file='c:\temp\test.pdf' notoc;

ods layout absolute y=.25in x=.25in width=10.5in height=8in;

 

ods region height=1in style={background=cyan};

ods text = '^{style [font_face=arial fontsize=16pt vjust=m just=center] Test Title}';

ods layout end;

ods pdf close;

 

 

I would think the above code would center the title horizontally and vertically but on the former occurs.  ??

 

--Ben


Accepted Solutions
Solution
‎07-19-2016 02:36 PM
Regular Contributor
Posts: 179

Re: vjust usage in a region

Hi Cynthia,

 

I have that one in a collection on my desk as well as the wonderful ones you have written. 

 

Chevell in T.S. found the key to what was happening: apparently to get it to work I also need the cellheight=xxin option as well.  that tells the style interpreter how high the area is it needs to center.  That seems awkard that it doesn't default to the region height.  Even a warning would be nice.  But as long as I can control it, I'm good. 

 

So the final ODS TEXT statement would be:

 

ods text = "^{style=[vjust=center just=center cellheight=3in] Test Title}";

 

Thanks!

 

--Ben

View solution in original post


All Replies
Super User
Posts: 9,856

Re: vjust usage in a region

vjust=center just=center
SAS Super FREQ
Posts: 8,815

Re: vjust usage in a region

Hi:

  Well, you might have stumbled on an issue. Taking ODS LAYOUT out of the picture and just seeing whether the VJUST works when there's no ODS LAYOUT involved, I have discovered that VJUST does not appear to impact ODS TEXT the same way it does a title statement. For example, compare these 3 outputs. To create this output, I had to make the font smaller (so it would not fill the height and so the impact of VJUST would be evident). I used a STYLE template because that removes the possibility of any strange formatting issues with ODS ESCAPECHAR. I also changed to the Arial Unicode MS font, which is the version of Arial that I have always been encouraged to use with PDF.

 

  Without ODS LAYOUT or ODS ESCAPECHAR in the picture, the results are not happy:

possible_problem_with_vjust.png

 

As you can see, the VJUST style attribute worked for the SAS TITLE statement, but did NOT work for ODS TEXT, even though all the other attributes worked for ODS TEXT.

 

You may have stumbled onto something that has been a problem with ODS TEXT for a while. So if this is the behavior without involving ODS LAYOUT or ODS ESCAPECHAR, I would not expect the behavior to be any different with ODS LAYOUT or ODS ESCAPECHAR.

 

  This might be something to work on with Tech Support, but given that the behavior doesn't work without ODS LAYOUT, they'd have to figure out what THAT is about -- but they might have a workaround for your text string using ODS LAYOUT. OR, since the vjust works in the TITLE statement, you might try that.

 

  Just remember, the bigger your font, the less you will see the impact of VJUST. So, for example, if I change my code to 28pt, then this is all I see because the value of vjust will not really be apparent the larger the font is:

vjust28.png

 

cynthia

 

Here's the code I used:

ods html close;

** 1 Top vertical justification;
ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);

proc template;
  define style styles.tltop;
    parent=styles.pearl;
	class SystemTitle /
	   vjust=top
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
	class UserText /
	   vjust=top
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
  end;
run;

options orientation=landscape topmargin=0.05in bottommargin=0.05in rightmargin=0.05in leftmargin=0.05in;
title;

ods PDF file='c:\temp\reg_title_top.pdf' notoc startpage=no style=styles.tltop;
ods escapechar='^';
title 'TOP Title';
ods text = 'TOP Title';

proc print data=sashelp.class(obs=1);
run;
 

ods pdf close;


** 2 Bottom vertical justification;

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);

proc template;
  define style styles.tlbot;
    parent=styles.pearl;
	class SystemTitle /
	   vjust=bottom
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
	class UserText /
	   vjust=bottom
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
  end;
run;

options orientation=landscape topmargin=0.05in bottommargin=0.05in rightmargin=0.05in leftmargin=0.05in;
title;

ods PDF file='c:\temp\test_reg_bot.pdf' notoc startpage=no style=styles.tlbot;
ods escapechar='^';

title 'BOT Title';
ods text = 'BOT Title';

proc print data=sashelp.class(obs=1);
run;

ods pdf close;


** 3 Middle vertical justification;

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);

proc template;
  define style styles.tlmid;
    parent=styles.pearl;
	class SystemTitle /
	   vjust=m
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
	class UserText /
	   vjust=m
	   just=center
	   background=pink
	   height=.5in
       fontsize=6pt
       fontweight=bold
       font_face='Arial Unicode MS';
  end;
run;

options orientation=landscape topmargin=0.05in bottommargin=0.05in rightmargin=0.05in leftmargin=0.05in;
title;

ods PDF file='c:\temp\test_reg_mid.pdf' notoc startpage=no style=styles.tlmid;
ods escapechar='^';

title 'MID Title';
ods text = 'MID Title';

proc print data=sashelp.class(obs=1);
run;

ods pdf close;
Regular Contributor
Posts: 179

Re: vjust usage in a region

Hi Cynthia,

 

Thanks, will run it by TS; what I'm actually trying to print isn't a title, but embedded in a much more complex layout.  At least it wasn't something I was missing.

 

Much appreciated!

 

--Ben

SAS Super FREQ
Posts: 8,815

Re: vjust usage in a region

Hi, Ben:
Probably a good idea. I thought this paper by Scott Huntley might also be useful for you: http://support.sas.com/resources/papers/proceedings15/SAS1836-2015.pdf

Good luck with your complex layout and Tech Support.

cynthia
Solution
‎07-19-2016 02:36 PM
Regular Contributor
Posts: 179

Re: vjust usage in a region

Hi Cynthia,

 

I have that one in a collection on my desk as well as the wonderful ones you have written. 

 

Chevell in T.S. found the key to what was happening: apparently to get it to work I also need the cellheight=xxin option as well.  that tells the style interpreter how high the area is it needs to center.  That seems awkard that it doesn't default to the region height.  Even a warning would be nice.  But as long as I can control it, I'm good. 

 

So the final ODS TEXT statement would be:

 

ods text = "^{style=[vjust=center just=center cellheight=3in] Test Title}";

 

Thanks!

 

--Ben

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 515 views
  • 0 likes
  • 3 in conversation