I'm pretty new to using SAS for creating graphs and charts. I copied some programming from a SAS program I found online and it did help create a graph that I like, but the names overlap. I was wondering if there was a way to create something that wouldn't overlap? I have provided the code and attached the chart.
proc boxplot data=Work.FruitOutliers;
plot ErrorPer*DateofReport /
boxstyle=schematicid
nohlabel;
id Outliers;
label ErrorPer = 'Errors';
run;
goptions reset=symbol;
Should be doable with GTL. This is an example from the documentation and you should have the SASHELP.CARS data set it uses.
proc template; define statgraph boxplot; begingraph; entrytitle "City Mileage for Vehicle Types"; layout overlay / xaxisopts=(offsetmin=0.1 offsetmax=0.1); boxplot y=mpg_city x=type / datalabel=make spread=true; endlayout; endgraph; end; run; proc sgrender data=sashelp.cars template=boxplot; label type="Vehicle Type"; run;
You would obviously change the text for Entrytitle (or remove entirely) and specify your variables for X= and y=. Datalabel=Make tells SAS to use the value the Make variable as a label for the outliers. The Spread=True horizontally spreads values that are the same on the Y axis so you can see separate markers to the labels may have issues if you have lots of these. You would also change the Sgrender code to reference your data set and likely the Label of the X variable. It would use any default label for your X and Y variables on the axis labels.
The xaxisopts used provide some space between the boxes on the left and right limits of the graph. Sometimes the defaults will crowd things up to the limits of the graph area.
Reeza,
I work with aylee214 and we are working on this chart together. We would be glad to try using SGPLOT, but after looking at the linked examples, we were not sure whether there is a way to add labels? For example, in this picture, the various fruit names are shown (which we like), but we want to somehow make it cleaner so that the names don't overlap. Would a VBOX or HBOX statement allow us to do that? Thanks for your help, we appreciate it!
Should be doable with GTL. This is an example from the documentation and you should have the SASHELP.CARS data set it uses.
proc template; define statgraph boxplot; begingraph; entrytitle "City Mileage for Vehicle Types"; layout overlay / xaxisopts=(offsetmin=0.1 offsetmax=0.1); boxplot y=mpg_city x=type / datalabel=make spread=true; endlayout; endgraph; end; run; proc sgrender data=sashelp.cars template=boxplot; label type="Vehicle Type"; run;
You would obviously change the text for Entrytitle (or remove entirely) and specify your variables for X= and y=. Datalabel=Make tells SAS to use the value the Make variable as a label for the outliers. The Spread=True horizontally spreads values that are the same on the Y axis so you can see separate markers to the labels may have issues if you have lots of these. You would also change the Sgrender code to reference your data set and likely the Label of the X variable. It would use any default label for your X and Y variables on the axis labels.
The xaxisopts used provide some space between the boxes on the left and right limits of the graph. Sometimes the defaults will crowd things up to the limits of the graph area.
ballardw,
Thank you! Once we tried your code as a template and substituted our data it worked like a charm and looks so much better than before!
Thank you, thank you!!!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.