BookmarkSubscribeRSS Feed
alfred1
Calcite | Level 5

Hello, everyone!

 

I'm using proc report to create tables and I can't figure out how to vertically align the report in the middle of the page.

My data does not have a consistent number of rows and some of them only have 1 row while some can take up a whole page.

Here is a sample using sashelp.cars. The layout of my data is very similar to this.

 

data test1; set sashelp.cars;
run;

ods escapechar="^";
ods pdf file="D:\folders\myfolders\zzz test\test.pdf" uniform style=journal;
options leftmargin=0.25in rightmargin=0.25in topmargin=0.25in bottommargin=0.25in;
options nobyline nodate nonumber;
options missing="";

proc report data=test1
style(column)={fontsize=12pt} 
style(header)={fontsize=13pt fontweight=bold fontstyle=roman}
style(report)={frame=void}
;
by make;
columns make model type origin drivetrain msrp;
define make / group noprint;
define origin / group noprint;
define model / display style=[width=3in];
define type / display style=[width=1.95in just=c];
define drivetrain / display style=[width=1.5in just=c];
define msrp / display style=[width=1.5in just=c];

compute before _page_ / center;
length text1 $300;
length text2 $300;

text1= " ^{style[font_size=24pt font_weight=bold]Make: } ^{style[font_size=24pt]" ||strip(make)|| "}";
text2= " ^{style[font_size=24pt font_weight=bold]Origin: } ^{style[font_size=24pt]" ||strip(origin)||  "}";

line text1 $300.;
line " ";
line text2 $300.;
line " ";

endcomp;

run;

ods pdf close;

Current result:

alfred1_0-1633477917510.png

Wanted result:

test.PNG

I tried changing the top margin to something like 2in or adding multiple extra line " "; before the text but it's not the same as putting each table in the center of the page since each table does not have the same number of rows.

 

Thank you for the help!

 

Alfred

2 REPLIES 2
acordes
Rhodochrosite | Level 12
Go to Lisa Fine's paper for further reading.
PROC REPORT
by Example
Techniques for Building
Professional Reports Using SAS®

Adapt the following code to your needs.

compute before _PAGE_ / left; ➓
length text0 - text6 $100;
if _BREAK_=' ' then
do;
text0="^{style [font_size=12 pt textdecoration=underline]"
||strip(type2)||" MSRP Price Point}";
text1="MSRP <=25th Percentile ("
||strip(put(per25.sum,dollar10.))||") ($)";
text2="MSRP <=50th Percentile ("
||strip(put(per50.sum,dollar10.))||") ($$)";
text3="MSRP <=75th Percentile ("
||strip(put(per75.sum,dollar10.))||") ($$$)";
text4="MSRP > 75th Percentile ("
||strip(put(per75.sum,dollar10.))||") ($$$$)";
text5=
"^{style [font_face=wingdings font_size=12 pt foreground=blue]n}"
||"Lowest MSRP: " || strip(put(pmin.sum,dollar10.));
text6=
"^{style [font_face=wingdings font_size=12 pt foreground=red]n}"
||"Highest MSRP: " || strip(put(pmax.sum,dollar10.));
end;

** Put New Variables in Line Statements;
line text0 $100.;
line '';
line text1 $100.;
line text2 $100.;
line text3 $100.;
line text4 $100.;
line '';
line text5 $100.;
line text6 $100.;
endcomp;

compute before make;
line '';
endcomp;
run;





alfred1
Calcite | Level 5
Thank you for responding. I'm not really looking to add summary statistics at the top of the page. I'm looking for a way to simply put reports in the middle of the page. Changing the top margin or adding more line " "; statements on top does not really help since every page has a different number of rows. If I add "options center" it centers the report within the left and right margins. I would like to center it from the top and bottom margins.

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 845 views
  • 0 likes
  • 2 in conversation