BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zhangda
Fluorite | Level 6

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;

1 ACCEPTED SOLUTION

Accepted Solutions
lopezr
Obsidian | Level 7

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

View solution in original post

5 REPLIES 5
rogerjdeangelis
Barite | Level 11
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;
zhangda
Fluorite | Level 6

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!

lopezr
Obsidian | Level 7

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;

 

zhangda
Fluorite | Level 6

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;

 

 

lopezr
Obsidian | Level 7

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 10727 views
  • 1 like
  • 3 in conversation