- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to make a plot in PROC SGPANEL with an axis break. Using
data new; input Type $1 Value; datalines; A 10 B 15 C 12 D 17 E 205 F 225 ; run; proc sgplot data=new; vbar type / response=value; yaxis ranges=(0-20 200-230); run;
(this is from https://support.sas.com/kb/55/683.html) works well in SGPLOT, but I seem to be unable to do something similar in SGPANEL. Any ideas ?
- Tags:
- proc sgpanel
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To emulate the behavior of PROC SGPANEL, you can use the
statement to arrange a set of plots that are produced by using PROC SGPLOT. You can use the
BY statement in PROC SGPLOT to produce a set of plots, each of which will have a broken axis.
For example:
data new;
input Group Type $ Value;
datalines;
1 A 10
1 B 15
1 C 12
1 D 17
1 E 205
1 F 225
2 A 12
2 B 18
2 C 19
2 D 10
2 E 215
2 F 212
;
/* use PROC SORT, if necessary, to sort the data by the BY group */
ods graphics / width=300px height=250px;
ods layout gridded columns=2 advance=BYGroup column_gutter=5px;
proc sgplot data=new;
by Group;
vbar type / response=value;
yaxis ranges=(0-20 200-230);
run;
ods layout end;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
rowaxis type=log;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To emulate the behavior of PROC SGPANEL, you can use the
statement to arrange a set of plots that are produced by using PROC SGPLOT. You can use the
BY statement in PROC SGPLOT to produce a set of plots, each of which will have a broken axis.
For example:
data new;
input Group Type $ Value;
datalines;
1 A 10
1 B 15
1 C 12
1 D 17
1 E 205
1 F 225
2 A 12
2 B 18
2 C 19
2 D 10
2 E 215
2 F 212
;
/* use PROC SORT, if necessary, to sort the data by the BY group */
ods graphics / width=300px height=250px;
ods layout gridded columns=2 advance=BYGroup column_gutter=5px;
proc sgplot data=new;
by Group;
vbar type / response=value;
yaxis ranges=(0-20 200-230);
run;
ods layout end;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. I can see how this would work (even if I was hoping for an easier solution)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need to create a panel plot with 4 subsidiary scatter plots, with a broken Y axis, and I also need to insert a different Pearson correlation coefficient for each scatter plot. SGPANEL allow me to use the INSET statement with variables, but the INSET statement in SGPLOT only allows me to use text strings. Is there any solution please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
use PROC SGPLOT to create whatever graphs you want. Use ODS LAYOUT gridded to arrange them into a panel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If the hold up is the placement of text then you might want to look at the TEXT plot.
Add a variable to hold the Text you want to display with the X, Y coordinates in the same variables as the Scatter plot.
data addedtext; infile datalines dlm=','; length textval $ 50; input textval height weight ; datalines; Short side of graph,50,60 Tall side of graph,70,120 ; data toplot; set sashelp.class addedtext ; run; proc sgplot data=toplot; scatter x=height y=weight/group=sex nomissinggroup; text x=height y=weight text=textval/ ; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@SimonYT wrote:
Thanks! The inset statement can do something similar. I have 4 different scatter plots with broken Y axis to be placed into one panel. Neither the inset nor the text statement allows for a 'group' option, which means we may have to use four different sgplot steps under one 'ods layout' statement to realize a panel plot.
You need to describe exactly what you mean by "group" option. Because the TEXT statement does use a group option though maybe not in the way that you want.
Really, you should start you own thread, provide example data and the sgplot you have tried so far.
For one thing since this thread was marked "solved" many people won't bother looking. Another thing is that the original poster of a question you can mark a solution as accepted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For your question, yes, I can make it clear. By 'group' I mean variable, for example, the inset statement within sgpanel can accept variable values, not just texts or strings. Does this answer your question?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@SimonYT wrote:
Thanks for taking time, appreciated. This is a follow-up question, no need to start a new thread, as people searching online will find related messages grouped together by the same thread. I don't quite understand your personal 'should' and 'should not'. I posted my though and contributed to the same thread. If it bothers you, you may step aside please.
For your question, yes, I can make it clear. By 'group' I mean variable, for example, the inset statement within sgpanel can accept variable values, not just texts or strings. Does this answer your question?
But it isn't.
You want Scatter, OP is VBAR. They are different plots and react differently when combined, or attempted, with other plots.
OP was ONLY concerned with the AXIS, you want INSET text or similar.
And you haven't actually clarified the group issue because TEXT statement Group= option does take a variable, in fact pretty much requires one when used.
Not to mention the OP provides some data and attempted plot code...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For your question, I suggest you to read SAS Manual’s Inset statement under ‘sgpanel’, which is different from that of sgplot in that it takes on variable values. Hope you understand my point.