BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Golf
Pyrite | Level 9

Hello,

    I have 5 series and would like to plot them separately but in one page.  

I used the following procedure:

Golf_0-1589206881476.png

But these graphs show in the same plane as follow.

Golf_1-1589206951107.png

How can I plot them separately but shown in one page.

Thank you.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Try this:

 

proc sgscatter data=ARDL;

plot (Inbank Inset Incpi fed nil)*date / join markerattrs=(size=0);

run;

 

Hope this helps!

Dan 

View solution in original post

8 REPLIES 8
ballardw
Super User

It isn't clear what you want put you might need to reshape your data so that instead of using 5 different y variables you create data with one y value and an indicator variable to show which value. Then use SGPANEL with a PANELBY statement.

 

Here is an example using a data set you should have available showing an SGPLOT similar to yours, reshaping the data then using SGPANEL.

I use a scatter because the data isn't really nice if plotting with "series", but the principle is the same.

proc sgplot data=sashelp.class;
   scatter x=age y=height ;
   scatter x=age y=weight ;
run; 

data reshape;
   set sashelp.class;
   value=Height;
   Valname='Height';
   output;
   value=weight;
   Valname='Weight';
   output;
run;

proc sort data=reshape;
   by valname;
run;

proc sgpanel data=reshape;
   panelby valname /columns=1 uniscale=column ;
   scatter x=age y=value;
run;
Golf
Pyrite | Level 9

Dear  ballardw,

  That is what I want.   The result is here.     However, I would like to know if I can plot the graph without sharing the scale of Y axis?

Thank You.

Capture.PNG

ballardw
Super User

If you place multiple graphs on a row within SGPANEL you are pretty restricted as to AXIS values range

The example I provided creating a single row per topic and the Uniscale=column option should use a different Y axis for each graph.

If you need more control of appearances and options you start moving into the Graphic Template Language and proc template to describe things. Lots more options but lots more stuff you have to provide and I can't find any quick/simple example that shows two different y axis examples (at least for more than two categories overall) on a single row.

Golf
Pyrite | Level 9
Thank You.
Rick_SAS
SAS Super FREQ

See the example and discussion in the article "Plotting multiple series: Transforming data from wide to long." The basic technique is to convert the data from wide to long and then use PROC SGPANEL.

DanH_sas
SAS Super FREQ

Try this:

 

proc sgscatter data=ARDL;

plot (Inbank Inset Incpi fed nil)*date / join markerattrs=(size=0);

run;

 

Hope this helps!

Dan 

Golf
Pyrite | Level 9
Thank You. Finally, I got it.
RichardDeVen
Barite | Level 11

You can use ODS LAYOUT GRIDDED to get independent Y-axes for each plot, or you can TRANSPOSE the data and accept the gridding that SGPANEL produces.

 

Example:

data have;
  do x = 1 to 20;
    y1 = 100 + x;
    y2 = x;
    y3 = x**2;
    y4 = (x-5)**3;
    y5 = 30 - x;
    output;
  end;
run;

proc transpose data=have out=tall;
  by x;
  var y1-y5;
run;

title; footnote;

ods html path='.' file='plots.html';

ods layout gridded columns=2 advance=proc;

proc sgplot data=have; series x=x y=y1;
proc sgplot data=have; series x=x y=y2;
proc sgplot data=have; series x=x y=y3;
proc sgplot data=have; series x=x y=y4;
proc sgplot data=have; series x=x y=y5;
run;

ods layout end; 

proc sgpanel data=tall;
  panelby _name_ / novarname noheaderborder;
  series x=x y=col1;
  rowaxis display=(nolabel);
run;

ods html close;

Output ODS LAYOUT GRIDDED

RichardADeVenezia_0-1589220723822.png

 

Output SGPANEL PANELBY

RichardADeVenezia_1-1589220757678.png

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2366 views
  • 7 likes
  • 5 in conversation