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:
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'
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'
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;
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.