Data visualization with SAS programming

ods pdf startpage=no; and graph

Reply
Regular Contributor
Regular Contributor
Posts: 156

ods pdf startpage=no; and graph

Dear all,

I'd like to display on a pdf first some text (my heading) and then a graph which should follow the text on the same page. Unfortunately SAS does a page break after the text and puts the Graph on a new page although I stated

ods pdf startpage=no; Here is my code (I use SAS 9.2 and the graph is correctly displayed yet on the wrong page):

ods pdf open;

ods pdf text = "mytext";

ods pdf startpage = no;

goptions device = sasprtc;

proc gchart data=mydata;

     vbar mynumericvalue / group = mygrouping freq = mynumber patternid = midpoint freq discrete raxis = axis1 maxsi = axis2 gaxis = axis3;

     axis1 label=(h=10 angle=90 'my text') minor=none;

     axis2 label=none;

     axis3 label=none;

run;

ods pdf close;

Is there anything with which I can stop SAS from putting the graph on a new page?

Best wishes

Eva

SAS Employee
Posts: 16

Re: ods pdf startpage=no; and graph

You were so close.  The reason the graph went to the second page is that there was not sufficient size on the page to place it there.  By default in PDF SAS/GRAPH tries to use the entire page  for the graph unless a size has been specified.

pdf file="test.pdf" startpage=no;

text="my text";

goptions vsize=6in border;

gchart data=sashelp.class;

age;run;quit;

pdf close;

Regular Contributor
Regular Contributor
Posts: 156

Re: ods pdf startpage=no; and graph

Dear Dan,

with goptions vsize = 6in now the graph is on the first page but the ods pds text is not shown.

And I have another problem (which occured before as well). I want to disply the page numbers in the footnote:

ods escapechar = '~';

footnote "Page ~{thispage} of ~{lastpage}";

The footnote is displayed but thispage and lastpage are displayed just as it is written between the " and ". This does not happen when I display a table with proc report.

Eva

SAS Employee
Posts: 16

Re: ods pdf startpage=no; and graph

Eva,

What release are you using.  The example that I posted worked for me at 9.2 and at 9.3.  I see that the code that I posted was truncated though. So I will try to repost it now.

ods pdf file="test.pdf" startpage=no;

ods text="my text";
goptions vsize=6in border;

proc gchart data=sashelp.class;

vbar age;run;quit;
ods pdf close;

The ~{thispage} and ~{lastpage} not working with graphs yet.

Regular Contributor
Regular Contributor
Posts: 156

Re: ods pdf startpage=no; and graph

Dear all,

I solved the problem now by not using ods pdf text=""; but instead title ""; Now the text and the graph are shown on the same page.

pdf and graph is always a bit tricky.

I use SAS 9.2 on UNIX with the SAS portal.

Best wishes

Eva

Valued Guide
Posts: 765

Re: ods pdf startpage=no; and graph

hi ... following produced 1 page (but so did startpage=no ... using V9.3 in windows XP) ...

ods results off;
ods listing close;

ods pdf file='z:\test.pdf'
        text = "This is a plot of weight and height using SASHELP.CLASS."
        startpage=never
        notoc
;

goptions reset=all ftext='calibri' htext=2 gunit=pct;

* move plot away from text;
title ls=2;

* move plot away from bottom edge;
footnote1 ls=2;


symbol1 f='wingdings' v='6c'x c=blue;

proc gplot data=sashelp.class;
plot weight * height / noframe;
run;
quit;


ods pdf close;
ods results;
ods listing;

Regular Contributor
Regular Contributor
Posts: 156

Re: ods pdf startpage=no; and graph

Dear Mike,

I read in the manuel that startpage=never should be used with graphs. So I tried it but it didn't work either. Maybe this is due to the SAS version, although I found the hint in the manual for SAs 9.1.3 and I use 9.2 on Win XP

Eva

Valued Guide
Posts: 765

Re: ods pdf startpage=no; and graph

hi ... just tried it in V9.2 ... two pages versus one in V9.3

you are correct !!!

SAS Employee
Posts: 16

Re: ods pdf startpage=no; and graph

We try to urge people to not use the startpage=never.  It just has never worked very well.

Regular Contributor
Regular Contributor
Posts: 156

Re: ods pdf startpage=no; and graph

It does work with table though in my example. The problem seems to be with graphs.

Ask a Question
Discussion stats
  • 9 replies
  • 2651 views
  • 0 likes
  • 3 in conversation