Hi,
I am new to playing around with PROC TEMPLATE. I am trying to output some tables to Word. When I use just the style Pearl, it works fine and I get the output I want (specifically, each cell has a single-line border) except for the font:
I want to change the font to Times New Roman, so I create a custom style using Pearl and just change the font. When I do this, I get the font changes I want, but then the single-line border from Pearl changes to double-lines:
How do I keep the borders/everything else in Pearl with just changing the font? I am using SAS 9.4. TIA!
proc template;
define style styles.pearlcustom;
parent = styles.pearl;
style data /
font_face = "Times New Roman"
font_size = 12pt
just = center
vjust = c
;
run;
%let outputword = "&path\Output..docx";
options nonumber nodate ls=200 ps=80 missing = "" formchar="|----|+|---+=|-/\<>*" orientation=landscape;
ods escapechar='^';
ods listing close;
options center;
title; footnote;
ods word file= &outputword style=styles.pearlcustom;
proc report data=&study._regsumm nowindows spacing=1 headline headskip split="|";
columns ('Results' (parameter &timepoints));
define parameter / display center "Parameter"
style(column)=[ font_size=12pt cellwidth=150 asis=on]
style(Header)=[ cellwidth=150 font_weight=bold font_size=12pt asis=on];
%macro summtimes;
%do i=1 %to &tcount;
define t&i / display left "&&time&i"
style(column)=[font_size=12pt cellwidth=150 asis=on]
style(column)={just=c}
style(Header)=[cellwidth=150 font_weight=bold font_size=12pt asis=on];
%end;
%mend summtimes;
%summtimes;
title1 justify=center bold font=ArialBlack height=12pt "Study Results";
footnote1 justify=center font=ArialBlack height=7pt "Created by &name on" " &sysdate..";
run;
title;
footnote;
ods word close;
Hi:
An easier way to "touch" all the fonts used by a changed style template is to just change the font table, as shown below:
ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
proc template;
define style Styles.times;
parent = styles.pearl;
class fonts /
'TitleFont2' = ("Times New Roman, Times",10pt,bold)
'TitleFont' = ("Times New Roman, Times",11pt,bold)
'StrongFont' = ("Times New Roman, Times",8pt,bold)
'EmphasisFont' = ("Times New Roman, Times",8pt,italic)
'headingEmphasisFont' = ("Times New Roman, Times",9pt,bold italic)
'headingFont' = ("Times New Roman, Times",8pt,bold)
'docFont' = ("Times New Roman, Times",8pt);
end;
run;
ods pdf file='c:\temp\times.pdf' style=styles.times;
proc print data=sashelp.class;
title 'custom style change fonts';
run;
proc freq data=sashelp.class;
tables age;
run;
ods pdf close;
When I do this, I get the correct borders and the font seems to be used. I only changed the proportional spaced fonts in the font table. I did not bother to change any of the "fixed" or "batch" monospace fonts in the style template definition.
Cynthia
The style for Data applies to the body of a table.
I think you need to look at the style for HEADINGS.
On my SAS 9.4.7 install this is the definition of Pearl style. There are multiple Headings that may be needed to set. Your "Results" text in the table is of a different size than the column headings as an example.
define style Styles.Pearl; parent = styles.printer; class fonts / 'TitleFont2' = ("<MTsans-serif>, Albany AMT",10pt,bold) 'TitleFont' = ("<MTsans-serif>, Albany AMT",11pt,bold) 'StrongFont' = ("<MTsans-serif>, Albany AMT",8pt,bold) 'EmphasisFont' = ("<MTsans-serif>, Albany AMT",8pt,italic) 'FixedEmphasisFont' = ("<MTmonospace>, Courier",7pt) 'FixedStrongFont' = ("<MTmonospace>, Courier",7pt,bold) 'FixedHeadingFont' = ("<MTmonospace>, Courier",7pt,bold) 'BatchFixedFont' = ("SAS Monospace, <MTmonospace>, Courier",6pt) 'FixedFont' = ("<MTmonospace>, Courier",7pt) 'headingEmphasisFont' = ("<MTsans-serif>, Albany AMT",9pt,bold italic) 'headingFont' = ("<MTsans-serif>, Albany AMT",8pt,bold) 'docFont' = ("<MTsans-serif>, Albany AMT",8pt); class GraphFonts / 'NodeDetailFont' = ("<MTsans-serif>, Albany AMT",7pt) 'NodeInputLabelFont' = ("<MTsans-serif>, Albany AMT",9pt) 'NodeLabelFont' = ("<MTsans-serif>, Albany AMT",9pt) 'NodeTitleFont' = ("<MTsans-serif>, Albany AMT",9pt) 'GraphAnnoFont' = ("<MTsans-serif>, Albany AMT",10pt) 'GraphTitle1Font' = ("<MTsans-serif>, Albany AMT",14pt,bold) 'GraphTitleFont' = ("<MTsans-serif>, Albany AMT",11pt,bold) 'GraphFootnoteFont' = ("<MTsans-serif>, Albany AMT",10pt) 'GraphLabelFont' = ("<MTsans-serif>, Albany AMT",10pt) 'GraphLabel2Font' = ("<MTsans-serif>, Albany AMT",10pt) 'GraphValueFont' = ("<MTsans-serif>, Albany AMT",9pt) 'GraphUnicodeFont' = ("<MTsans-serif-unicode>",9pt) 'GraphDataFont' = ("<MTsans-serif>, Albany AMT",7pt); class colors / 'link2' = cx0000FF 'link1' = cx800080 'docbg' = cxFFFFFF 'contentbg' = cxFFFFFF 'systitlebg' = cxFFFFFF 'titlebg' = cxFFFFFF 'proctitlebg' = cxFFFFFF 'headerbg' = cxFFFFFF 'captionbg' = cxFFFFFF 'captionfg' = cx000000 'bylinebg' = cxFFFFFF 'notebg' = cxFFFFFF 'tablebg' = cxFFFFFF 'batchbg' = cxFFFFFF 'systitlefg' = cx000000 'titlefg' = cx000000 'proctitlefg' = cx000000 'bylinefg' = cx000000 'notefg' = cx000000; class GraphColors / 'goffill' = cx666666 'gofill' = cxf6f6f6 'govbline' = cx848b93 'gobline' = cx848b93 'gncdata12' = cxF9DA04 'gncdata11' = cxB38EF3 'gncdata10' = cx47A82A 'gncdata9' = cxD17800 'gncdata8' = cxB26084 'gncdata7' = cx2597FA 'gncdata6' = cx7F8E1F 'gncdata5' = cx9D3CDB 'gncdata4' = cx543005 'gncdata3' = cx01665E 'gncdata2' = cxA23A2E 'gncdata1' = cx445694 'gncdata' = cx445694 'gndata12' = cxEFEAC4 'gndata11' = cxDEDAF8 'gndata10' = cxC9E6C0 'gndata9' = cxE9D0AE 'gndata8' = cxE8C3D4 'gndata7' = cxCEE1F1 'gndata6' = cxDFE0B5 'gndata5' = cxDEC9E8 'gndata4' = cxD8C8B5 'gndata3' = cxBAD6D4 'gndata2' = cxE9B5B5 'gndata1' = cxC4CFE7 'gndata' = cxC4CFE7 'gnclink' = cx969696 'gnlink' = cxC4C4C4 'gntext' = cx111111 'gblockheader' = cxcfd5de 'gcphasebox' = cx86898B 'gphasebox' = cxC2C9D8 'gczonec' = cxB7C2DA 'gzonec' = cxCBD3E3 'gczoneb' = cxC0CBE4 'gzoneb' = cxD2D9E9 'gzonea' = cxDBE2F1 'gcunder' = cxD059E2 'gunder' = cxD059E2 'gcover' = cx70A1E9 'gover' = cx70A1E9 'gcfinal' = cx85894D 'gfinal' = cx85894D 'gcinitial' = cxF3D532 'ginitial' = cxF3D532 'gcother' = cx70A1E9 'gother' = cx70A1E9 'gcmiss' = cx979797 'gmiss' = cxc3c3c2 'gablock' = cxF5F5F0 'gblock' = cxDFE6EF 'gcclipping' = cxC1C100 'gclipping' = cxFFFFC6 'gcstars' = cx445694 'gstars' = cxCAD5E5 'gcruntest' = cxBF4D4D 'gruntest' = cxCAE3FF 'gccontrollim' = cxBFC7D9 'gcontrollim' = cxE6F2FF 'gdata' = cxCAD5E5 'gcdata' = cx003399 'goutlier' = cxB9CFE7 'gcoutlier' = cx000000 'gfit2' = cx780000 'gfit' = cx003178 'gcfit2' = cxDC531F 'gcfit' = cx667FA2 'gconfidence2' = cxE3D5CD 'gconfidence' = cxB9CFE7 'gcconfidence2' = cxE3D5CD 'gcconfidence' = cxE3D5CD 'gpredict' = cx667FA2 'gcpredict' = cx445694 'gpredictlim' = cx7486C4 'gcpredictlim' = cx7486C4 'gerror' = cxCA5E3D 'gcerror' = cxA33708 'greferencelines' = cx989EA1 'gheader' = colors('docbg') 'gout2cend' = cx919191 'gout2cstart' = cxe9e9e9 'gconramp3cend' = cx9C1C00 'gconramp3cneutral' = cx222222 'gconramp3cstart' = cx0E36AC 'gramp3cend' = cxD05B5B 'gramp3cneutral' = cxFAFBFE 'gramp3cstart' = cx667FA2 'gconramp2cend' = cxA23A23 'gconramp2cstart' = cxFFF1EF 'gramp2cend' = cx445694 'gramp2cstart' = cxF3F5FC 'gtext' = cx000000 'glabel' = cx000000 'gborderlines' = cx919191 'goutlines' = cx000000 'gmgrid' = cxF2F2F2 'ggrid' = cxE6E6E6 'gaxis' = cx86898B 'gshadow' = cx8F8F8F 'gfloor' = cxDCDAC9 'glegend' = cxFFFFFF 'gwalls' = colors('docbg') 'gckran5' = cx609530 'gkran5' = cx7BB04A 'gckran4' = cx9CB12D 'gkran4' = cxB8CC49 'gckran3' = cxD4BD2D 'gkran3' = cxF2D94B 'gckran2' = cxC2792D 'gkran2' = cxE09346 'gckran1' = cxB23D2E 'gkran1' = cxD15845 'gcdata12' = cxF9DA04 'gdata12' = cxDDD17E 'gcdata11' = cxB38EF3 'gdata11' = cxB7AEF1 'gcdata10' = cx47A82A 'gdata10' = cx87C873 'gcdata9' = cxD17800 'gdata9' = cxCF974B 'gcdata8' = cxB26084 'gdata8' = cxCD7BA1 'gcdata7' = cx2597FA 'gdata7' = cx94BDE1 'gcdata6' = cx7F8E1F 'gdata6' = cxBABC5C 'gcdata5' = cx9D3CDB 'gdata5' = cxB689CD 'gcdata4' = cx543005 'gdata4' = cxA9865B 'gcdata3' = cx01665E 'gdata3' = cx66A5A0 'gcdata2' = cxA23A2E 'gdata2' = cxD05B5B 'gcdata1' = cx445694 'gdata1' = cx6F7EB3; style GraphBackground from GraphBackground "Graph background attributes" / backgroundcolor = colors('docbg') color = colors('docbg'); style GraphGridLines from GraphGridLines "Grid line attributes"; style GraphMinorGridLines from GraphMinorGridLines "Minor Grid line attributes"; class Graph / attrpriority = "Color"; class GraphFit2 / linestyle = 1; class GraphClipping / markersymbol = "circlefilled"; style Table from Table / cellpadding = 5pt borderspacing = .05pt borderwidth = .1pt frame = box bordercolor = cx919191 bordercollapse = collapse; class Header / color = cx000000 backgroundcolor = cxFFFFFF bordercolor = cxB0B7BB bordercollapse = collapse; class RowHeader / color = cx000000 backgroundcolor = cxFFFFFF bordercolor = cxB0B7BB bordercollapse = collapse; class Footer / color = cx000000 backgroundcolor = cxFFFFFF bordercolor = cxB0B7BB bordercollapse = collapse; class RowFooter / color = cx000000 backgroundcolor = cxFFFFFF bordercolor = cxB0B7BB bordercollapse = collapse; class batch / borderwidth = 0px; class Data / font = fonts('DocFont') backgroundcolor = _undef_ bordercolor = cx919191 bordercollapse = collapse; class DataEmphasis / font = fonts('DocFont') backgroundcolor = _undef_ bordercolor = cx919191 bordercollapse = collapse; class Heading1 / fontsize = 11pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; class Heading2 / fontsize = 10pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; class Heading3 / fontsize = 9pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; class Heading4 / fontsize = 8pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; class Heading5 / fontsize = 7pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; class Heading6 / fontsize = 6pt fontweight = bold fontfamily = "<MTsans-serif>, Albany AMT"; end;
Hi:
An easier way to "touch" all the fonts used by a changed style template is to just change the font table, as shown below:
ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);
proc template;
define style Styles.times;
parent = styles.pearl;
class fonts /
'TitleFont2' = ("Times New Roman, Times",10pt,bold)
'TitleFont' = ("Times New Roman, Times",11pt,bold)
'StrongFont' = ("Times New Roman, Times",8pt,bold)
'EmphasisFont' = ("Times New Roman, Times",8pt,italic)
'headingEmphasisFont' = ("Times New Roman, Times",9pt,bold italic)
'headingFont' = ("Times New Roman, Times",8pt,bold)
'docFont' = ("Times New Roman, Times",8pt);
end;
run;
ods pdf file='c:\temp\times.pdf' style=styles.times;
proc print data=sashelp.class;
title 'custom style change fonts';
run;
proc freq data=sashelp.class;
tables age;
run;
ods pdf close;
When I do this, I get the correct borders and the font seems to be used. I only changed the proportional spaced fonts in the font table. I did not bother to change any of the "fixed" or "batch" monospace fonts in the style template definition.
Cynthia
This worked! Thank you so much
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.
Ready to level-up your skills? Choose your own adventure.