BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eh51
Calcite | Level 5

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

FreelanceReinh
Jade | Level 19

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1171 views
  • 2 likes
  • 3 in conversation