- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-11-2011 11:04 AM
(4885 views)
how can I get bars groups placed side by side with sgplot like you get from gplot
PROC GCHART DATA=sumsboth;
VBAR Lag / discrete TYPE=SUM SUMVAR=percent_success_both GROUP=year_quarter ref=99 frontref cref=red
FRAME
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
PATTERNID=MIDPOINT
;
PROC GCHART DATA=sumsboth;
VBAR Lag / discrete TYPE=SUM SUMVAR=percent_success_both GROUP=year_quarter ref=99 frontref cref=red
FRAME
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
PATTERNID=MIDPOINT
;
13 REPLIES 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For SAS 9.2, you have to be a little creative. For SAS 9.3, there will be an option to get side-by-side groups in SGPLOT. In the meantime, try this example below. Your group variable will go on the PANELBY statement. There are other options on the PANELBY statement to move the column headings (columnheaderpos) and to remove the label part of the column heading (novarlabel).
Hope this helps,
Dan
[pre]
proc sgpanel data=sashelp.class;
panelby sex / layout=columnlattice onepanel noborder;
vbar age / response=height;
run;
[/pre]
Hope this helps,
Dan
[pre]
proc sgpanel data=sashelp.class;
panelby sex / layout=columnlattice onepanel noborder;
vbar age / response=height;
run;
[/pre]
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
close except for a couple things
my value for year_quarter is truncated to just 20
also they want the vertical scale adjusted as
yaxis values=(90 91 93 94 95 96 97 98 100);
would affect the scale with sgplot
I don't see any way of doing that with sgplanel
Message was edited by: wkossack Message was edited by: wkossack
my value for year_quarter is truncated to just 20
also they want the vertical scale adjusted as
yaxis values=(90 91 93 94 95 96 97 98 100);
would affect the scale with sgplot
I don't see any way of doing that with sgplanel
Message was edited by: wkossack Message was edited by: wkossack
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The VALUES option can be specified on the ROWAXIS statement to control the scaling of the vertical axis. Was the trucation on the axis or the column headings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
column headings.
I think there is not enough space. I looked up the ROWAXIS. All I really need is for the value to be displayed not the variable name i.e. 2010_Q1 not year_quarter = 2010_Q1
I think there is not enough space. I looked up the ROWAXIS. All I really need is for the value to be displayed not the variable name i.e. 2010_Q1 not year_quarter = 2010_Q1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the NOVARNAME option on the PANELBY statement to get rid of the variable label.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
OK that worked but I have not gotten colaxis to work
I'm using
COLAXIS values=(90 to 100 by 1) ;
I'm using
COLAXIS values=(90 to 100 by 1) ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You need to use the ROWAXIS statement instead of the COLAXIS statement. The row axes are the vertical axes and and the column axes are the horizontal axes.
Thanks!
Dan
Thanks!
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Arg....should have realized that
is there any way I can overlay a line plot with sgpanel?
I have another variable I want to overlay with an additional vertical axis. For example, my bars are the percent error but I want to overlay a line that is the sample size
is there any way I can overlay a line plot with sgpanel?
I have another variable I want to overlay with an additional vertical axis. For example, my bars are the percent error but I want to overlay a line that is the sample size
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can overlay a VLINE chart on the VBAR chart; however, we do not currently support secondary axes for SGPANEL. For the time being, you can use GTL to do it. Here is an example:
[pre]
proc template;
define statgraph barline;
begingraph /;
layout gridded / rowgutter=5;
layout datalattice columnvar=Sex / includeMissingClass=false rowDataRange=unionall columnDataRange=unionall rows=1
rowAxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ))
columnAxisOpts=(type=Discrete display=all altdisplay=all)
row2AxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ));
layout prototype / wallDisplay=(fill);
ReferenceLine y=0 / lineattrs=GraphAxisLines;
BarChart X=Age Y=Height / primary=true LegendLabel="Height" NAME="VBAR";
SeriesPlot X=Age Y=Weight / LegendLabel="Weight" yaxis=y2 NAME="VLINE";
endlayout;
endlayout;
DiscreteLegend "VBAR" "VLINE";
endlayout;
endgraph;
end;
run;
proc summary data=sashelp.class nway;
class sex age;
var weight height;
output out=temp mean=;
run;
proc sgrender data=temp template=barline; run;
[/pre]
[pre]
proc template;
define statgraph barline;
begingraph /;
layout gridded / rowgutter=5;
layout datalattice columnvar=Sex / includeMissingClass=false rowDataRange=unionall columnDataRange=unionall rows=1
rowAxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ))
columnAxisOpts=(type=Discrete display=all altdisplay=all)
row2AxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ));
layout prototype / wallDisplay=(fill);
ReferenceLine y=0 / lineattrs=GraphAxisLines;
BarChart X=Age Y=Height / primary=true LegendLabel="Height" NAME="VBAR";
SeriesPlot X=Age Y=Weight / LegendLabel="Weight" yaxis=y2 NAME="VLINE";
endlayout;
endlayout;
DiscreteLegend "VBAR" "VLINE";
endlayout;
endgraph;
end;
run;
proc summary data=sashelp.class nway;
class sex age;
var weight height;
output out=temp mean=;
run;
proc sgrender data=temp template=barline; run;
[/pre]
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
this generates a number of errors
for starters
rowAxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ))
___________
180
42 ! columnAxisOpts=(type=Discrete display=all altdisplay=all) row2AxisOpts=( offsetmin=0 display=all altdisplay=all
42 ! linearOpts=( viewmin=0 )); layout prototype / wallDisplay=(fill); ReferenceLine y=0 /
ERROR 180-322: Statement is not valid or it is used out of proper order.
for starters
rowAxisOpts=( offsetmin=0 display=all altdisplay=all linearOpts=( viewmin=0 ))
___________
180
42 ! columnAxisOpts=(type=Discrete display=all altdisplay=all) row2AxisOpts=( offsetmin=0 display=all altdisplay=all
42 ! linearOpts=( viewmin=0 )); layout prototype / wallDisplay=(fill); ReferenceLine y=0 /
ERROR 180-322: Statement is not valid or it is used out of proper order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Secondary axis support for DATALATTICE was added in SAS 9.2m3. What version of SAS 9.2 do you have?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
EG 4.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ah there it is 9.2M1