Hello,
I have 5 series and would like to plot them separately but in one page.
I used the following procedure:
But these graphs show in the same plane as follow.
How can I plot them separately but shown in one page.
Thank you.
Try this:
proc sgscatter data=ARDL;
plot (Inbank Inset Incpi fed nil)*date / join markerattrs=(size=0);
run;
Hope this helps!
Dan
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;
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.
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.
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.
Try this:
proc sgscatter data=ARDL;
plot (Inbank Inset Incpi fed nil)*date / join markerattrs=(size=0);
run;
Hope this helps!
Dan
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
Output SGPANEL PANELBY
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!
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.
Ready to level-up your skills? Choose your own adventure.