BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BenConner
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
BenConner
Pyrite | Level 9

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

5 REPLIES 5
Ksharp
Super User
vjust=center just=center
Cynthia_sas
SAS Super FREQ

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;
BenConner
Pyrite | Level 9

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

Cynthia_sas
SAS Super FREQ
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
BenConner
Pyrite | Level 9

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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