BookmarkSubscribeRSS Feed
Garnett
Obsidian | Level 7

I get some strange behavior when using 'ods pdf columns=2' approach to generating two columns of plots with sgplot. The problem lies with the keylegend option in sgplot.

I want to generate six plots: plots1-4 in the left column and plots 5-6 in the right column.

Consider the following example. The program behaves properly when the 'keylegend' statement is commented out. However, if the 'keylegend' is used, then the right columns disappear. This has nothing to do with the location = option. The option can be omitted (so that an empty keylegend appears in the code) and the right column still vanishes.

%macro plt;

%do i = 1 %to 6;

%if i = 5 %then %do; ods pdf startpage = now; %end;

ods graphics on / reset = all height = 3.75 in width = 7 in noborder  ;

proc sgplot data = d1;

      series x = x y = y / group = g;

      %*KEYLEGEND  / LOCATION = INSIDE ;

      inset "Plot&i.";

run;

ods graphics off;

%end;

%mend plt;

**** Play Data ****;

data d1; do g = 1,2;    do x = 1 to 10; y=x+g; output; end; end; run;

options orientation=portrait pageno = 1 ;

ods pdf file = "c:\TEST &SYSDATE..pdf" startpage = never ;

ods pdf columns = 2;

ods pdf startpage = now;

%plt;

ods pdf close;

6 REPLIES 6
Jay54
Meteorite | Level 14

Which version of SAS are you using?  This runs correctly on SAS 9.2(TS2M3).  See attached output file.

Garnett
Obsidian | Level 7

Interesting! I use 9.3....

DanO_sas_com
SAS Employee

There were a number of defects associated with the startpage option in 9.2 which have been fixed in 9.3.   In 9.2 you had to do that startpage=never/now jive.  That is no longer necessary.   The correct 9.3 code would be as follows.

ods pdf file="c:\TEST &SYSDATE..pdf" startpage=no columns=2;

%plt;

ods pdf close;

I noticed that you also had a "width=7in" in your plt macro which is incorrect, and is being ignored.  You have a portrait letter page which is 8.5inx11in  minus the .25in margins all around, so you actually have 8inx10.5in of available. space. The columns= options evenly divides the available space into evenly size columns.  So your available width for each column happens to be 4in.

Garnett
Obsidian | Level 7

Many thanks for your help. I made your suggested change and reduced the height/width to 2x4inches. 

I still don't get the correct output when KEYLEGEND is included....

JoySmith
Calcite | Level 5

I am also having problems with ODS pdf and startpage=never.

I am using  ODS pdf to create a report from several statistical procedures and using startpage=never.

It works in 9.2 but in 9.3 my first page is a blank page with only the title...:smileyconfused:

Joy

ScottH_SAS
SAS Employee

Joy,

If you could send me a small snippet of your code to ODS@sas.com I will take a look at it and offer some suggestions.  Smiley Happy

Scott

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 1386 views
  • 0 likes
  • 5 in conversation