BookmarkSubscribeRSS Feed
Alphanumeric
Obsidian | Level 7

SAS 9.2 is being used.

I am attempting to place a gplot graph within a PDF using ODS. This is a pre-existing ODS with several proc reports laid out within. Sadly, it is not as easy as simply placing another ODS PDF startpage and pasting the proc gplot into the body of code. The graph works on its own and outputs to PDF fine on a single page, but when placing it within the larger ODS code it comes up blank. The PDF output displays all the proc reports fine, but a blank page is inserted where the gplot was placed in the code. The results window also shows the graph without error. The code is as follows:

*Set pdf options here;

options

    missing =' '

    nodate

          nonumber

          orientation=portrait

          center

          leftmargin   =0in

          rightmargin  =0in

          topmargin    =0.5in

          bottommargin =0in

;

goptions ftext='Arial' htext=2 gunit=pct ctext=black csymbol=blue DEVICE=PDFC;

symbol1 i =sms value=none c=black  w =1 l=3;

symbol2 i =join value=circle c=red    w =2;

symbol3 i =join value=dot  c =blue   w =2;

   axis1

     label=(angle=90 h=1 'label1')

     order=(0 to 90 by 10)

     minor=(n=5);

   axis2

     label=none

           order=(0 to 160 by 13)

     value=(tick=1  h=1 '3/2011'

            tick=2  h=1 '6/2011'

            tick=3  h=1 '9/2011'

            tick=4  h=1 '12/2011'

            tick=5  h=1 '3/2012'

            tick=6  h=1 '6/2012'

            tick=7  h=1 '9/2012'

            tick=8  h=1 '12/2012'

            tick=9  h=1 '3/2013'

            tick=10 h=1 '6/2013'

            tick=11 h=1 '9/2013'

            tick=12 h=1 '12/2013'

            tick=13 h=1 '3/2014')

     minor=(n=12)

     offset=(2,2)

     ;

* Open ODS and set up PDF document path;

ods pdf (ID=Cdrive) file="C:\temp.pdf" notoc

    style=style.Print startpage=no;

*Set the escape character here for use throughout the program;

ods escapechar = '^';

     title  H=5 "Title1";

     title3 H=4 "title2";

     footnote1 h=8pt j=l "%sysfunc(today(),mmddyy10.)" j=r " page ^{thispage} of ^{lastpage}";

proc report data=data1 nowd;

    column var1 var2 var3;

              define var1     / display;

        define blank    / " " center format=NoDot. style=[cellwidth=10mm];

        define var2     / display;

                    define var3     / display;

run;

ods pdf (ID=Ldrive) text='^{newline 6}';

ods pdf (ID=Ldrive) text = '^S={just=center font=("Arial, Helvetica, Helv",4)}Next report, same page';

proc report data=data2 nowd;

    column var1 var2 var3;

              define var1     / display;

        define blank    / " " center format=NoDot. style=[cellwidth=10mm];

        define var2     / display;

                    define var3     / display;

run;

ods pdf (ID=Ldrive) text='^{newline 6}';

ods pdf (ID=Ldrive) text = '^S={just=center font=("Arial, Helvetica, Helv",4)}Third report, same page';

proc report data=data3 nowd;

    column var1 var2 var3;

              define var1     / display;

        define blank    / " " center format=NoDot. style=[cellwidth=10mm];

        define var2     / display;

                    define var3     / display;

run;

* Start the PDF page with this report here;

ods pdf (ID=Ldrive) startpage=yes;

title  H=3pt "Graph title1";

title2 H=2pt "Graph title2";

proc gplot

          data=gplottbl;

          plot  ttlcnt*week (totPenn totLvll)*week /overlay haxis=axis2 vaxis=axis1 ANNOTATE=my_labels ;

run;

quit;

* Start the PDF page with this report here;

ods pdf (ID=Ldrive)  style=style.Online  startpage=yes;

title  H=5 "title1";

title3 H=5 "title2";

proc report data=data4 nowd;

    column var1 var2 var3;

              define var1     / display;

        define blank    / " " center format=NoDot. style=[cellwidth=10mm];

        define var2     / display;

                    define var3     / display;

run;

ods pdf (ID=Ldrive) close;

goptions reset=all;

ods listing;

This is an abbreviated version of the program and the data/labels/titles have been renamed, but this is it. I have attempted resetting and not using goptions, I have tried placing the gplot at the beginning and end and elsewhere in the report, dropped all the titles, removed the footnote to the PDF (which is another question entirely), but I am obviously missing something. The log file brings up these issues:

SASissue.jpg

While I did attempt to adjust both HSIZE and VSIZE, I continually get this resizing warning that is always 1 inch shorter no matter what size I set each value.

I have a feeling I am missing something simple here, and my SAS programming skills are not superior by any stretch... but this is leaving me frustrated.

Thanks for taking a look.

9 REPLIES 9
ballardw
Super User

Your example code does not appear to assign an output file for the id of Ldrive. So the snippage to reduce your code to the problem area may be missing something.

Also, id you try this without the DEVICE=PDFC? I don't use PDF very much but have never botherd to use the DEVICE options and the graphs display fine.

Alphanumeric
Obsidian | Level 7

Yeah, I was attempting to strip out the identifying info and forgot to change the Ldrive file name to Cdrive. They are Ldrive ids consistently throughout the real code. Thanks for the catch.

As to the second part, yes. I tried with and without device and even tried without any goptions at all. Still nothing and the same WARNING code.

~jJ

GraphGuy
Meteorite | Level 14

I don't use pdf often, and I'm therefore not familiar with all the in's and out's ...

But I experimented with your code a bit, and found that if you comment out the 'footnote' then the graph shows up.  (I'm not sure why that is, but I thought I'd mention it ... maybe some of the other pdf experts can provide more insight).

Here's a smaller test program, using sashelp.class data, so people can more easily experiment:

%let name=pdf003;

options missing =' ' nodate nonumber orientation=portrait center
leftmargin=0in rightmargin=0in topmargin=0.5in bottommargin=0in ;

goptions ftext='Arial' htext=2 gunit=pct ctext=black csymbol=blue DEVICE=PDFC;

/*
footnote1 h=8pt j=l "%sysfunc(today(),mmddyy10.)" j=r " page ^{thispage} of ^{lastpage}";
*/

/* report #1 */
ods pdf (ID=Cdrive) file="&name..pdf" notoc startpage=no;
ods escapechar = '^';
PROC REPORT NOWD DATA=sashelp.class;
COL sex weight;
RUN;

/* Report #2 */
ods pdf (ID=Ldrive) text='^{newline 6}';
ods pdf (ID=Ldrive) text = '^S={just=center font=("Arial, Helvetica, Helv",4)}Next report, same page';
PROC REPORT NOWD DATA=sashelp.class;
COL sex weight;
RUN;

/* Report #3 */
ods pdf (ID=Ldrive) text='^{newline 6}';
ods pdf (ID=Ldrive) text = '^S={just=center font=("Arial, Helvetica, Helv",4)}Third report, same page';
PROC REPORT NOWD DATA=sashelp.class;
COL sex weight;
RUN;

/* Graph #1 */
ods pdf (ID=Ldrive) startpage=yes;
title1 "Graph #1";
proc gplot data=sashelp.class;
plot height*weight;
run;
quit;

/* Report #4 */
ods pdf (ID=Ldrive) startpage=yes;
PROC REPORT NOWD DATA=sashelp.class;
COL sex weight;
RUN;

ods pdf (ID=Ldrive) close;
goptions reset=all;
ods listing;

Alphanumeric
Obsidian | Level 7

I'll give that a try again, but I did notice that in the single page graph output, the footnote was not producing on the page.

update: seems to function now sans page of total pages footnote. Oddly enough, the footnote has no issue on the single ODS PDF graphic only document,

singlePDF.jpg

though it does drop the functional part of the code. I will have to hone my google-fu skills to figure out the why part now the the full report is up.

Thank you kindly Robert.

Cynthia_sas
SAS Super FREQ

Hi:

  There are a couple of Tech Support notes about using ODS ESCAPECHAR {LASTPAGE} function with images and PDF:

http://support.sas.com/kb/34/573.html

http://support.sas.com/kb/15/541.html

  

cynthia

KarlK
Fluorite | Level 6

Alphanumeric, Cynthia is, of course, right. What's catching you is her first tech note, I believe. Your post caught my eye because, unlike Robert Allison (who knows 13 million times more about SasGraph as I do), I mix graphics and text on PDFs all the time, and I knew your program "should" work. My workaround has just been to output a placeholder string in place of {lastpage}, not used anywhere else in the document, and then do a global search & replace in Acrobat.

Sorry I didn't see your post sooner.

Karl

Aman4SAS
Obsidian | Level 7

Can any one let me know how to use nodot. for format. i am getting error format nodot can be found.

Cynthia_sas
SAS Super FREQ

Hi, it appears that the NODOT. format is a user-defined format and so the only person who has the code for the user defined format would be the original poster. The quick fix would be to just remove format=nodot. from the code.

cynthia

ps...in the future, it's probably best not to "piggyback" on a 2 year old post. It would be better to start a new post and then provide a link to reference the post that had already been closed.

GraphGuy
Meteorite | Level 14

And if you don't want to bother with removing the format from the code, you could suppress the errors by using ...

options nofmterr;

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
  • 9 replies
  • 2742 views
  • 3 likes
  • 6 in conversation