I am generating comparative graphics with proc univariate. The y axis labels are very long - they are "class variable name = value", so for example "Owner location = Chicago".
I want to stack the histograms so have nrow=4 (or some other number). As the number of histograms in the panel increases, the y axis labels get truncated so all I see is 'Owner location ...". This shows to the left of each histogram.
In on-line resources, the graphs have the class variable shown to the far left of the graphic by itself, then between that and each histogram is the variable value for that histogram (e.g. 'Chicago', 'Houston', etc.) by itself. I like this format but cannot find the controls.
Can you help?
macro items should not impact this question or answer:
ods exclude Moments BasicMeasures TestsForLocation Quantiles MissingValues
ExtremeObs ParameterEstimates GoodnessOfFit FitQuantiles;
proc univariate data=work.wins;
class owner_location;
histogram &wpref._&stat /
normal (color = red w=3 l=2)
kernel (k=normal color=green w=3 l=1)
odstitle="&wtitle. (&stat.), &wtitle1p"
HREF=&whref HREFLABELS=&whreflbl
NROW=4;
format &wpref._&stat comma7.0;
&wwhere.
run;
In the PROC UNIVARIATE step you could insert a LABEL statement to specify a shorter variable label, e.g.
label owner_location='Loc.';
resulting in "Loc. = Chicago", etc. Independently, the values themselves could be abbreviated with a user-defined format (e.g. "Chicago" = "Chic."). Moreover, increasing the height of the plot (using the HEIGHT= option of the ODS GRAPHICS statement), if possible, would create more space for those labels.
@eh51 wrote:
In on-line resources, the graphs have the class variable shown to the far left of the graphic by itself, then between that and each histogram is the variable value for that histogram (e.g. 'Chicago', 'Houston', etc.) by itself. I like this format but cannot find the controls.
I think what you describe is the layout in traditional (SAS/GRAPH) graphics. So using that -- ods graphics off; -- would be another option.
If you want more control over graphs then typically the more flexible approach is to move to a graphing procedure such as Sgplot or Sgpanel. Since it appears that you may be running Univariate only to generate graphs that becomes a much stronger recommendation.
Sgpanel would allow use of your Class variable(s) on a panel by statement to create one histogram per combination. You have additional options to control how panels are arranged and content.
A brief example you could run as you should have the Sashelp.class data set available.
proc sgpanel data=sashelp.class; panelby sex /columns=1 novarname /*suppresses panelby variable name*/ ; histogram weight; run;
The class variable value appears at the top of each panel of the graph.
In the PROC UNIVARIATE step you could insert a LABEL statement to specify a shorter variable label, e.g.
label owner_location='Loc.';
resulting in "Loc. = Chicago", etc. Independently, the values themselves could be abbreviated with a user-defined format (e.g. "Chicago" = "Chic."). Moreover, increasing the height of the plot (using the HEIGHT= option of the ODS GRAPHICS statement), if possible, would create more space for those labels.
@eh51 wrote:
In on-line resources, the graphs have the class variable shown to the far left of the graphic by itself, then between that and each histogram is the variable value for that histogram (e.g. 'Chicago', 'Houston', etc.) by itself. I like this format but cannot find the controls.
I think what you describe is the layout in traditional (SAS/GRAPH) graphics. So using that -- ods graphics off; -- would be another option.
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.