Data visualization with SAS programming

SGPanel & ODS Layout - stretch chart across page

Reply
Frequent Contributor
Posts: 126

SGPanel & ODS Layout - stretch chart across page


I'm using ODS Layout and SGPanel and want the chart to fill the page. Is there a way to do this?

Thanks,

Brian Adams

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

I am using the ODS Layou code below but the panel chart doesn't fill the page. I would like the chart to be larger. Is there a way to do this?

sascode.png

Super Contributor
Posts: 543

Re: SGPanel & ODS Layout - stretch chart across page

Hi.

If you add

ODS PDF "\\your_path\plot_full_page.pdf";

...

your proc sgpnale code

...

ODS PDF CLOSE;

It fills the page.

Maybe I don't fully understand what would you like to accomplish at the end?:smileyconfused:

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Anca,

Thanks for the reply. Yes I do have that ODS PDF code sandwiched around my code. But the panel chart only fills about 70% of the available page area. I would like the chart to fill the entire page.

Thanks again,

Brian

Super Contributor
Posts: 543

Re: SGPanel & ODS Layout - stretch chart across page

Could you, please, try to change your width and height statement to:

width = 100pct height = 100pct;

Thanks!

Let me know if it works.

This is what I get -- see attached, using this code:

ods layout start width = 100pct height = 100pct;

ods escapechar = "^";

ods region width = 100pct height = 100pct ;*x = .1in y = .5in;

ods pdf file = "my_path....\plot.pdf";

proc sgpanel data = sashelp.class;

panelby sex/columns = 1 onepanel uniscale = all;

*format; *I don't have a format, but this shouldn't affect anything;

band x = height lower = 0 upper = 75/transparency= .5 legendlabel = "Height" fillattrs = (color = OLIVE);

series x = weight y = age/legendlabel = "Something" lineattrs = (color = MAROON thickness = 3);

run;

ods pdf close;

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Anca,

Thanks again for the reply. When I run your code I again get a panel chart that only fills about 70% of the page. The output you posted looks like it used Proc SGPlot. When I run the code below I get a plot that only fills about half the page. (P.S. is there any way to copy/paste my code into these posts?)

sgplot.jpg

SAS Super FREQ
Posts: 1,075

Re: SGPanel & ODS Layout - stretch chart across page

Try this.. This seems to works for me.

ods pdf file='c:\Plot.pdf';

ods graphics / reset width=100pct height=100pct;

proc sgplot data=sashelp.cars;

  histogram mpg_city;

  run;

ods pdf close;

ods pdf file='c:\Panel.pdf';

ods graphics / reset width=100pct height=100pct;

proc sgpanel data=sashelp.cars;

  panelby origin / layout=rowlattice onepanel;

  histogram mpg_city;

  run;

ods pdf close;

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Sanjay,

Thanks for the reply!

Unfortunately it is not doing for me what it is doing for you. I think there must be some system settings that need to be changed on my end. I'm still getting a chart that only fills about 70% of the page (see attached file).

Super Contributor
Posts: 543

Re: SGPanel & ODS Layout - stretch chart across page

Very interesting.

Did you try 1. GOPTIONS reset = all;

          2. Close SAS and open it again.

Smiley Happy

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Anca,

Thanks for the reply! I had great hopes that that would be the answer. But I did exactly what you suggested and I still get a chart that fills only about 70% of the page.

SAS Super FREQ
Posts: 1,075

Re: SGPanel & ODS Layout - stretch chart across page

I am checking with others here who know more about ODS Layout.  However, do you need the ODS LAYOUT and the ODS REGION statements?  These are pre-production, and may not be doing what you want.  The example I sent you does not have those statements.  Yes, try this in a fresh session of SAS as suggested by Anca.

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Sanjay,

Thanks for your help!

I copied the code you sent to a  new editor window and ran it without any of the ODS layout code and I still got the same results as before.

Frequent Contributor
Posts: 126

Re: SGPanel & ODS Layout - stretch chart across page

Anca & Sanjay,

I'm going to try running Sanjay's code on another pc to see if it's just something related to my installation. I'll let you know how it goes.

Thanks again!

SAS Super FREQ
Posts: 1,075

Re: SGPanel & ODS Layout - stretch chart across page

You may need to define rows and columns when using ODS LAYOUT in PDF.

Can you attach your full code?

ods _all_ close;

ods pdf file='c:\Panel.pdf';

ods layout start rows=1 columns=1;

ods region;

ods graphics / reset width=100pct height=100pct;

proc sgpanel data=sashelp.cars;

  panelby origin / layout=rowlattice onepanel;

  histogram mpg_city;

  run;

ods pdf close;

SAS Super FREQ
Posts: 1,075

Re: SGPanel & ODS Layout - stretch chart across page

You may be using some release of SAS 9.2.  In that case, the width=100% will not work on the ODS GRAPHICS statement will not work as it was not yet implemented for SAS 9.2.  Note ODS LAYOUT is pre-production and  it is implemented with SAS 9.3.

So, you will have to provide a specific size for the graph.  If this is a 8.5" x 11" page, I suggest using:

ods graphics / reset width=7.5in height=10in;

Ask a Question
Discussion stats
  • 14 replies
  • 902 views
  • 6 likes
  • 3 in conversation