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

Hi,

Trying to figure out how do I add titles to my 3 variables?

Below is my code:

 

ods graphics on;
proc univariate data=ford_2015 plot;
var city08 fuelcost08 displ;
histogram / normal odstitle = "City MPG for 2015 Fords"
"Annual Fuel cost for 2015 Fords""Engine Displacement in ltrs for 2015 Fords";
label city08 = "City MPG";
label fuelcost08 ="Annual Fuel cost";
label displ="Displacement in ltrs";
run;

upon running this code I get the following error:

histogram / normal odstitle = "City MPG for 2015 Fords"
78 "Annual Fuel cost for 2015 Fords""Engine Displacement in ltrs for 2015 Fords";
_____________________________________________________________________________
22
200
ERROR 22-322: Syntax error, expecting one of the following: ;, ANNOKEY, ANNOTATE, BARFILL, BARLABEL, BARWIDTH, BETA, CAXIS,
CBARLINE, CFILL, CFRAME, CFRAMESIDE, CFRAMETOP, CGRID, CHREF, CLIPCURVES, CLIPREF, CONTENTS, CPROP, CSTATREF, CTEXT,
CV, CVREF, DESCRIPTION, ENDPOINTS, EXPONENTIAL, FONT, FRONTREF, GAMMA, GRID, GUMBEL, HANGING, HAXIS, HEIGHT, HMINOR,
HOFFSET, HREF, HREFLABELS, HREFLABPOS, IGAUSS, INFONT, INHEIGHT, INTERBAR, INTERTILE, KERNEL, LGRID, LHREF,
LOGNORMAL, LSTATREF, LVREF, MAXNBIN, MAXSIGMAS, MIDPERCENTS, MIDPOINTS, NAME, NCOL, NCOLS, NENDPOINTS, NMIDPOINTS,
NOBARS, NOCHART, NOCURVELEGEND, NOFRAME, NOHLABEL, NOLEGEND, NOPLOT, NORMAL, NOTABCONTENTS, NOVLABEL, NOVTICK, NROW,
NROWS, ODSFOOTNOTE, ODSFOOTNOTE2, ODSTITLE, ODSTITLE2, OUTHISTOGRAM, OUTKERNEL, OVERLAY, PARETO, PFILL, POWER,
RAYLEIGH, RTINCLUDE, SB, STATREF, STATREFLABELS, STATREFSUBCHAR, SU, TILELEGLABEL, TURNVLABELS, VAXIS, VAXISLABEL,
VMINOR, VOFFSET, VREF, VREFLABELS, VREFLABPOS, VSCALE, WAXIS, WBARLINE, WEIBULL, WGRID, WHREF, WSTATREF, WVREF.
ERROR 200-322: The symbol is not recognized and will be ignored.
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I am not sure exactly what you want for the title but you can use the \l to use the label of a variable as part of the title. If you don't provide any other string then the variable label is all that would appear.

 

ods graphics on;
proc univariate data=sashelp.class ;
   var age height weight;
   histogram / normal odstitle='\l';
	label age ='Age at enrollment'
	      height= 'Height at graduation'
	      weight= 'Weight at lunch'
	;
run;
title;
ods graphics off;

 If you want the same text to appear at the end of the "title" then use

odstitle ='\l for 2015 Fords'

View solution in original post

5 REPLIES 5
ballardw
Super User

I am not sure exactly what you want for the title but you can use the \l to use the label of a variable as part of the title. If you don't provide any other string then the variable label is all that would appear.

 

ods graphics on;
proc univariate data=sashelp.class ;
   var age height weight;
   histogram / normal odstitle='\l';
	label age ='Age at enrollment'
	      height= 'Height at graduation'
	      weight= 'Weight at lunch'
	;
run;
title;
ods graphics off;

 If you want the same text to appear at the end of the "title" then use

odstitle ='\l for 2015 Fords'

PGStats
Opal | Level 21

Put your data into long format and use by-processing with #byval substitution in the title. Example:

 

data graph;
set sashelp.cars;
where make = "Ford";
value = EngineSize; parameter = "Engine Size"; output;
value = HorsePower; parameter = "Horse Power"; output;
value = Length; parameter = "Length"; output;
keep type parameter value;
run;

proc sort data=graph; by parameter; run;

title2 "Parameter = #BYVAL1";
proc univariate data=graph;
var value;
by parameter;
histogram / normal odstitle = "Ford Models" odstitle2=title2;
run;
PG
vedaj16
Calcite | Level 5
Thanks for your solution. I will keep this format for sure!
Ksharp
Super User

Try using multiple HISTOGRAM statement ?

proc univariate data=sashelp.class ;
   var age height weight;
   histogram age/ normal odstitle='age';
   histogram height/ normal odstitle='height';
   histogram weight/ normal odstitle='weight';
run;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2526 views
  • 2 likes
  • 4 in conversation