- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 09-24-2009 12:33 PM
(5863 views)
Hi all,
I am creating 2 vbars for actual and predicted sales using proc sgplot, I have the code and able to get perfect graph but it uses common y-axis.
I want different y-axis for actual and predicted.
Thanks for all your help.
Regards,
Amit
code:
data test;
set sashelp.prdsal2 (keep= monyr actual predict year);
where year eq 1995;
run;
proc summary data=test missing nway;
class monyr;
var actual predict;
output out=summary (drop= _type_ _freq_ ) sum=;
run;
proc sgplot data=summary;
vbar monyr / response=actual
fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
vbar monyr / response=predict
barwidth=.5 fillattrs=graphdata2 transparency=.25 name="Predict"
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
xaxis label=" " grid;
yaxis label=" " discreteorder=data;
run;
I am creating 2 vbars for actual and predicted sales using proc sgplot, I have the code and able to get perfect graph but it uses common y-axis.
I want different y-axis for actual and predicted.
Thanks for all your help.
Regards,
Amit
code:
data test;
set sashelp.prdsal2 (keep= monyr actual predict year);
where year eq 1995;
run;
proc summary data=test missing nway;
class monyr;
var actual predict;
output out=summary (drop= _type_ _freq_ ) sum=;
run;
proc sgplot data=summary;
vbar monyr / response=actual
fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
vbar monyr / response=predict
barwidth=.5 fillattrs=graphdata2 transparency=.25 name="Predict"
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
xaxis label=" " grid;
yaxis label=" " discreteorder=data;
run;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey Amit,
Currently, you cannot assign bar charts to secondary axes. However, you may be able to work around this depending on what you're trying to achieve. Why are you trying to asign the "predict" response to the Y2 axis? Is it just for axis labeling?
Thanks!
Currently, you cannot assign bar charts to secondary axes. However, you may be able to work around this depending on what you're trying to achieve. Why are you trying to asign the "predict" response to the Y2 axis? Is it just for axis labeling?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dan,
The data which I actually want to model have varying frequency.
for example say the Actual sales were in the thousands where as the predicted sales were in the hunreds. The small numbers (predicted) are not visible due to the large scale of Actual sales.
What would be a good way to represent it and show.
Thanks,
Amit
The data which I actually want to model have varying frequency.
for example say the Actual sales were in the thousands where as the predicted sales were in the hunreds. The small numbers (predicted) are not visible due to the large scale of Actual sales.
What would be a good way to represent it and show.
Thanks,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I modified your original example. Try these possibilities:
/* Veritcally oriented */
proc sgplot data=summary;
vbar monyr / response=actual fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
vline monyr / response=predict y2axis markers markerattrs=(symbol=circlefilled)
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
y2axis min=0 label=" " offsetmin=0;
xaxis label=" " grid ;
yaxis label=" " offsetmin=0 discreteorder=data; run;
/* Horizontally oriented */
proc sgplot data=summary;
hbar monyr / response=actual fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
hline monyr / response=predict x2axis markers markerattrs=(symbol=circlefilled)
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
x2axis min=0 label=" " offsetmin=0;
yaxis label=" " grid ;
xaxis label=" " offsetmin=0 discreteorder=data; run;
/* Veritcally oriented */
proc sgplot data=summary;
vbar monyr / response=actual fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
vline monyr / response=predict y2axis markers markerattrs=(symbol=circlefilled)
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
y2axis min=0 label=" " offsetmin=0;
xaxis label=" " grid ;
yaxis label=" " offsetmin=0 discreteorder=data; run;
/* Horizontally oriented */
proc sgplot data=summary;
hbar monyr / response=actual fillattrs=graphdata2 transparency=.65
legendlabel="Actual Sales" name="Actual";
hline monyr / response=predict x2axis markers markerattrs=(symbol=circlefilled)
legendlabel="Predicted Sales" name="Predict";
keylegend "Actual" "Predict";
x2axis min=0 label=" " offsetmin=0;
yaxis label=" " grid ;
xaxis label=" " offsetmin=0 discreteorder=data; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dan,
Thanks a lot.
Regards,
Amit
Thanks a lot.
Regards,
Amit