BookmarkSubscribeRSS Feed
bconner
Fluorite | Level 6

Good morning,

 

I'm experimenting with the best way to define a border around  an ODS region in an absolute layout example.  What I'd like to see is a thin black border, title text inside it and have the background of the region not be white.

Using the sample code:

 

%let st=fontfamily='Arial' fontsize=10pt just=c cellwidth=7.2in cellheight=.31in vjust=c background=cyan;

ods pdf file="c:\temp\weekly.pdf";

ods layout absolute y=0in x=0in;

ods region y=.5in x=.4in width=7.25in height=.35in style=[borderwidth=1 bordercolor=black];

ods text="^{style[&st]Test Title1^nTest Title2}";

ods layout end;

ods pdf close;

 

Produces something close but not quite there.  If I declare the cell height/width the exact same as the region size, the borders from the region style get overlaid.  Tried adding border information into the style for the ods text statement but that had no effect.  ?

 

Thanks!

 

--Ben

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:
You're writing ODS TEXT, not using a TITLE statement. Just curious. There is a TitleandFooterContainer in the style template that might work to turn the border on for the container. Not sure about ODS TEXT styles because those are controlled by a different style element.

I rarely use Absolute layout .. just never had the kind of output where I could always rely on the text strings and data to be predictable.

But without going down the ODS LAYOUT/ODS REGION road, I always like to see how I can do what is needed without the fancy stuff. So this is what I came up with:

 

make_title_text_box.png

 

Cyan background is regular SAS Title statement with a custom style template and pink background is regular ODS TEXT strings with a custom style template. I thought I would need to use TitleandFooterContainer in the template, but I was able to put the border control in the style element directly for SystemTitle and UserText.

 

Code is here:

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
 
proc template;
  define style makebox;
  parent=styles.pearl;
  class SystemTitle /
    frame=box
    background=cyan
	width=100%
	fontfamily='ArialUnicodeMS'
	fontsize=10pt
	fontweight=bold
	just=c
	vjust=m
	cellpadding=2px
	borderwidth=1px
	bordercolor=black
	color=black;

  class UserText from SystemTitle/
    frame=box
    background=pink
	width=100%
	fontfamily='ArialUnicodeMS'
	fontsize=10pt
	fontweight=bold
	just=c
	vjust=m
	cellpadding=2px
	borderwidth=1px
	bordercolor=purple
	color=black;
  end;
run;
 
options orientation=portrait center nodate nonumber 
        topmargin=1in bottommargin=1in leftmargin=1in rightmargin=1in;
		  
ods pdf file='c:\temp\usetitle_box.pdf' style=makebox;
title 'Test Title1^nTest Title2';
proc print data=sashelp.class(obs=1)
     style(table)={width=5in};
run;
ods pdf close;
title;

ods pdf file='c:\temp\useODSTEXT.pdf' style=makebox startpage=no;
ods text="Test Title1^nTest Title2";
proc print data=sashelp.class(obs=1)
     style(table)={width=5in};
run;
ods pdf close;
title;

Hope this helps give you some ideas.

 
Cynthia

bconner
Fluorite | Level 6

Hi Cynthia,

 

Yeah...most of the reports we do have very picky layout, so Absolute has been the tool of choice.  Also why I disabled titles, as I can't get those to line up exactly on top of a proc report and make it look like they grew there.

 

If I could make the area the title has sit exactly on top of the proc print, that would get close.  I'll play around with that and see if I can get it to work.

 

Thanks much!

 

--Ben

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2455 views
  • 1 like
  • 2 in conversation