Hi,
I want to add a text into the output of sas pdf file with sas ods pdf file, but how to style the text, such as how to move it to the center top of the table instead of being left? The code below is not working. Thank you so much!
options obs=10;
proc template;
define style Styles.MyStyle;
parent=styles.htmlblue;
style usertext from usertext /vjust=c ;
end;
run;
ods pdf file="C/Mtest29003.pdf" startpage=never notoc style=Styles.MyStyle ;
title "January Orders ";
footnote " For All Employees";
ods text="My Text 1";
ods text="My Text 2";
proc print data=sashelp.class;
run;
ods text="My Text 3";
ods pdf close;
title;
footnote;
proc template;
delete Styles.MyStyle ;
run;
Instead of width use the FONT_SIZE option to change the size.
This seems to center everything, including the table.
ods escapechar='^';
options center;
ods pdf file="d:/pdf/Mtest29003.pdf" startpage=never notoc ;
title j=c "January Orders ";
footnote j=c " For All Employees";
ods text="^S={just=c}My Text 3";
ods text="^S={just=c}My Text 3";
proc print data=sashelp.class;
run;
ods text="^S={just=c}My Text 3";
ods pdf close;
title;
footnote;
Hi Roger,
I really appreciate your help! but why it wont work after I put other styles into it, such as
ods text="^S={just=c foreground=black fontweight=bold width=1.9in }My Text 3"; it becomes left centered again especially I put the width=1.9in. Thank you so much!
To center justify text change the CLASS usertext not the style; the only problem is that this will center justify on the page and not based on your table.
proc template;
define style Styles.MyStyle;
parent=styles.htmlblue;
class usertext from usertext /just=c ;
end;
run;
One solution to have the text appear at the center top/bottom is to use PROC REPORT and include the text as part of your table.
ods pdf file="C:\Mtest29003.pdf" startpage=never notoc style=Styles.MyStyle ;
title "January Orders ";
footnote " For All Employees";
proc report data=sashelp.class;
column name sex age height weight;
compute before _page_/style={just=center bordertopcolor=white borderrightcolor=white borderleftcolor=white};
line "My Text 1";
line "My Text 2";
endcomp;
compute after/style={just=center borderbottomcolor=white borderrightcolor=white borderleftcolor=white };
line "My Text 3";
endcomp;
run;
ods pdf close;
title;
footnote;
Hi Lopez,
Do you know how to make "My Text 1" bigger? why it wont work when I put width=1.6in into the code? Thank you so much!
ods pdf file="C:\Mtest29003.pdf" startpage=never notoc style=Styles.MyStyle ;
title "January Orders ";
footnote " For All Employees";
proc report data=sashelp.class;
column name sex age height weight;
compute before _page_/style={just=center width=1.6in bordertopcolor=white borderrightcolor=white borderleftcolor=white};
line "My Text 1";
line "My Text 2";
endcomp;
compute after/style={just=center borderbottomcolor=white borderrightcolor=white borderleftcolor=white };
line "My Text 3";
endcomp;
run;
ods pdf close;
title;
footnote;
Instead of width use the FONT_SIZE option to change the size.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.