The SAS Output Delivery System and reporting techniques

How to center the text with ods pdf file?

Accepted Solution Solved
Reply
Contributor
Posts: 74
Accepted Solution

How to center the text with ods pdf file?

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;


Accepted Solutions
Solution
‎02-20-2017 11:05 AM
New Contributor
Posts: 4

Re: How to center the text with ods pdf file?

[ Edited ]

Instead of width use the FONT_SIZE option to change the size.

View solution in original post


All Replies
Valued Guide
Posts: 505

Re: How to center the text with ods pdf file?

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;
Contributor
Posts: 74

Re: How to center the text with ods pdf file?

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!

New Contributor
Posts: 4

Re: How to center the text with ods pdf file?

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;

 

Contributor
Posts: 74

Re: How to center the text with ods pdf file?

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;

 

 

Solution
‎02-20-2017 11:05 AM
New Contributor
Posts: 4

Re: How to center the text with ods pdf file?

[ Edited ]

Instead of width use the FONT_SIZE option to change the size.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 827 views
  • 1 like
  • 3 in conversation