BookmarkSubscribeRSS Feed
DanielKaiser
Pyrite | Level 9
Hello together,

i am a apprentice and started working on sas a few month ago.
Now i had to create a new style using Proc Template.

It worked really good by using the SUGI92 docs. but there are still two things left i need to know.

1. I had a Title and a Footnote, but the Footnote uses the same style like the Title
2. Before showing my output there is one single page without an out (only header image)

I hope you can help me. the base code is added.

Best regards so far.

Daniel





PROC TEMPLATE;
DEFINE STYLE HUK2;
PARENT = Styles.Printer;
STYLE fonts from fonts /
'TitleFont' = ("Arial",24pt)
'TitleFont2' = ("Arial",16pt)
'StrongFont' = ("Arial",10pt,Bold)
'EmphasisFont' = ("Arial",10pt,Italic)
'headingEmphasisFont' = ("Arial",10pt,Bold Italic)
'headingFont' = ("Arial",10pt,Bold)
'docFont' = ("Arial",10pt)
'FootFont' = ("Arial",5pt)
'FixedEmphasisFont' = ("Courier",9pt,Italic)
'FixedStrongFont' = ("Courier",9pt,Bold)
'FixedHeadingFont' = ("Courier",9pt,Bold)
'BatchFixedFont' = ("Courier",6.7pt)
'FixedFont' = ("Courier",9pt);
CLASS color_list /
'link' = blue /* links */
'bgH' = cxF4C61B /* row and column header background */
'fg' = black /* tabletext color */
'st' = cx6E6E6E /* system title color */
'pt' = cx969696 /* proc title color */
'ft' = #AAAAAA /* foot note color */
'bg' = white /* page background color */
'tb' = cx4F493B /* Table border color */
'cb' = cxDCDCDC /* Cell background color */
'tib' = cxF4C61B; /* Table Title background color */
CLASS Body from Document /
bottommargin = 0.25in
topmargin = 0.25in
rightmargin = 0.25in
leftmargin = 0.25in;
CLASS BODY FROM BODY /
PREIMAGE="\\lan\profil\PROFIL-PE\fat\AP448\XP-AWD\SAS\SharedSettings\Styles\HUKBanner.png";
CLASS TABLE /
padding = 5
borderspacing = 1px
frame = box
rules = all
bordertopwidth = 1px
borderleftwidth = 1px
borderbottomwidth = 1px
borderrightwidth = 1px
bordercolor = color_list('tb')
bordercollapse = separate;
CLASS COLORS /
'headerfgemph' = color_list('fg')
'headerbgemph' = color_list('tib')
'headerfgstrong' = color_list('fg')
'headerbgstrong' = color_list('tib')
'headerfg' = color_list('fg')
'headerbg' = color_list('tib')
'datafgemph' = color_list('fg')
'databgemph' = color_list('cb')
'datafgstrong' = color_list('fg')
'databgstrong' = color_list('cb')
'datafg' = color_list('fg')
'databg' = color_list('cb')
'batchbg' = color_list('fg')
'batchfg' = color_list('bg')
'tableborder' = color_list('fg')
'tablebg' = color_list('fg')
'proctitlefg' = color_list('pt')
'proctitlebg' = color_list('bg')
'titlefg' = color_list('fg')
'titlebg' = color_list('bg')
'systitlefg' = color_list('st')
'systitlebg' = color_list('bg')
'contentfg' = color_list('fg')
'contentbg' = color_list('bg')
'contitlefg' = color_list('fg')
'confolderfg' = color_list('fg')
'conentryfg' = color_list('fg')
'docfg' = color_list('fg')
'docbg' = color_list('bg')
'captionbg' = color_list('bg')
'captionfg' = color_list('fg')
'notefg' = color_list('fg')
'notebg' = color_list('bg')
'link2' = color_list('link')
'link1' = color_list('link')
'bylinebg' = color_list('bg')
'bylinefg' = color_list('fg')
'gheader' = color_list('st');
class GraphBackground /
backgroundcolor = white
color = white;
END;
RUN;
ODS PDF FILE = 'Y:\SAMPLE.PDF' STYLE=HUK2;
TITLE 'Titel';
FOOTNOTE 'Fußnote';
PROC PRINT DATA = SASHELP.CLASS;
RUN;
ODS PDF CLOSE;

Message was edited by: DJDaniel Message was edited by: DJDaniel
7 REPLIES 7
Cynthia_sas
SAS Super FREQ
Hi:
I see in your code where you DEFINE the FootFont style attribute in the fonts element. I do not, however, see where you USE the element.

Without any instruction from you, the TitleFont will be used for the SAS Footnote because of this style element definition in STYLES.DEFAULT (the parent template for STYLES.PRINTER):
[pre]
SystemTitle and SystemFooter elements from STYLES.DEFAULT:
class SystemTitle /
font = Fonts('TitleFont');
class SystemFooter /
font = Fonts('TitleFont');
[/pre]

As you can see, in STYLES.DEFAULT, both the SystemTitle element -AND- the SystemFooter element use the TitleFont attribute from the Fonts element. Focussing only on the Footnote issue, then, you will need to put a CLASS statement into your style template, as shown below, to USE the FootFont attribute which you have inserted into the Fonts element.

For your other issue, I believe that, in some instances, when you use an image, you might get an automatic page break in PDF unless you use the STARTPAGE=NO option on your ODS PDF statement. However, when I use the example in this SGF paper (use the preimage on STYLE TABLE element), I get the image and the table on the same page, without a page break in between. I note that you put your image reference in the BODY element. Perhaps you should try the TABLE element instead. Paper reference:
http://support.sas.com/resources/papers/proceedings10/035-2010.pdf (pages 1 & 2)

cynthia
[pre]
ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);

PROC TEMPLATE;
DEFINE STYLE HUK2;
PARENT = Styles.Printer;
STYLE fonts from fonts /
'TitleFont' = ("Arial",24pt)
'TitleFont2' = ("Arial",16pt)
'StrongFont' = ("Arial",10pt,Bold)
'EmphasisFont' = ("Arial",10pt,Italic)
'headingEmphasisFont' = ("Arial",10pt,Bold Italic)
'headingFont' = ("Arial",10pt,Bold)
'docFont' = ("Arial",10pt)
'FootFont' = ("Arial",5pt) /* need to USE setting */
'FixedEmphasisFont' = ("Courier",9pt,Italic)
'FixedStrongFont' = ("Courier",9pt,Bold)
'FixedHeadingFont' = ("Courier",9pt,Bold)
'BatchFixedFont' = ("Courier",6.7pt)
'FixedFont' = ("Courier",9pt);
class SystemFooter /
font = Fonts('FootFont');

END;
RUN;

ODS PDF FILE = 'c:\temp\SAMPLE.PDF' STYLE=HUK2;
TITLE 'Titel';
FOOTNOTE 'Fußnote';
PROC PRINT DATA = SASHELP.CLASS;
RUN;
ODS PDF CLOSE;
[/pre]
DanielKaiser
Pyrite | Level 9
Ok. Thank you very much.

Well. There is one other thing left to ask 🙂

If i print my output to pdf the table width isn´t really comfortable. is there a possibility that the width get automatic as width of it´s content?

Best regard. And have a nice weekend.

Daniel
Cynthia_sas
SAS Super FREQ
Hi:
I'm not sure of 2 things. First, I'm not sure what you mean when you say "the width isn't comfortable" -- you could mean that the table wraps oddly, that the margins are too big or that the table splits across pages; second, you ask whether there is a possibility for "the width get automatic as width of it´s content". This question implies to me that somehow your content is too wide for the page?? But you could mean, also that individual cells are wrapping and are not wide enough.

Let me address the second question. ODS PDF has a lot of factors to take into account beyond the formatted width of each cell in your table. Because ODS PDF uses a proportional spaced font for the output -- the size of the font is only one factor. The font itself contains space between letters and space around letters that must be factored in. Then there is the orientation system option -- is it set to portrait or landscape (or some other value). Next, even with portrait or landscape, ODS PDF must factor in the margins for each edge of the paper: topmargin, bottommargin, rightmargin and leftmargin. And, on top of that, the cellpadding around the contents of a cell must be factored in, as well as whether the table needs to accomodate interior table lines or cell borders, and if so, what type of lines and how thick the lines are. So the idea of "automatic" adjusting for width is already being done -- but the basis for the table width is more than just the formatted width of the cell contents. ODS PDF is not like the LISTING window or the LISTING destination. Nor, is it like ODS HTML -- an HTML table can be as wide or as narrow as it needs to be.

Here is a previous forum posting that shows the use of system options and various STYLE= overrides to impact the width of tables in ODS RTF and ODS PDF compared to ODS HTML:
http://support.sas.com/forums/thread.jspa?messageID=414ƞ

In essence, understanding how ODS PDF works will help you fix your first issue/question of the table width not being "comfortable".

cynthia
DanielKaiser
Pyrite | Level 9
Well. Thats difficult for me. I am not that good in english 🙂

Well if i have a table:

Cell1 | Cell2 | Cell3

then in the output it is like this:

Ce | Ce | Ce
ll1 | ll2 | ll3

it brokes the word in the title.
Cynthia_sas
SAS Super FREQ
OK... let's try this:
1) What is the system option for orientation?
2) What are your margin settings?
3 What does your data look like? How many cells do you have going ACROSS the page (only 3???) Cell1, Cell2, Cell3? Or do you have MORE column going ACROSS the page?? Such as Cell1-Cell50??
4) What procedure are you using? PROC PRINT, PROC REPORT, PROC TABULATE?

When I run this code, I do not observe any values wrapping in the cell or in the column headers (although the headers probably would wrap in the LISTING window) -- but you said you were interested in ODS PDF.

cynthia

To run the code: cut and paste from the Forum posting area into Microsoft Word or some other editor which will "respect" the line breaks. Then cut and paste from Word into SAS in order to test and run the code.

[pre]
data makecell;
array cl cell1-cell50;
do grp = 'aaa', 'bbb', 'ccc', 'ddd';
do i = 1 to 50 by 1;
cl(i) = ranuni(i) *10;
end;
output;
end;
format cell1-cell50 2.;
run;

ods listing close;
options orientation=landscape
topmargin=.5in bottommargin=.5in
rightmargin=.5in leftmargin=.5in;
ods pdf file='c:\temp\testwidth.pdf' notoc;

proc report data=makecell nowd;
column grp cell1-cell50;
define grp / order id;
run;

ods pdf close;
[/pre]
DanielKaiser
Pyrite | Level 9
1) What is the system option for orientation?
2) What are your margin settings?
3 What does your data look like? How many cells do you have going ACROSS the page (only 3???) Cell1, Cell2, Cell3? Or do you have MORE column going ACROSS the page?? Such as Cell1-Cell50??
4) What procedure are you using? PROC PRINT, PROC REPORT, PROC TABULATE?

1) I set it to landscape
2) My settings are the same like yours. But if i change them it doesn´t show any effect
3) The number of columns is variable
4) I use Proc Print

I tried your example. The header of the cells looks now fine but the Obs is seperated to Ob [newline] s

Best regards.
Cynthia_sas
SAS Super FREQ
Hi:
I do not observe the same behavior that you describe. For example, if I add a PROC PRINT to the above code, there is no split of the header value 'Obs'.

My recommendation would be that you open a track with Tech Support. They can gather information on your operating system, look at your exact data and all your code and see whether they can replicate your PDF behavior.

To open a track with Tech Support, fill out the form at this link:
http://support.sas.com/ctx/supportform/createForm

cynthia

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
  • 7 replies
  • 1115 views
  • 0 likes
  • 2 in conversation