Perhaps you specified the syntax incorrectly. The HREF= option is avilable in ODS graphics, as shown in the following example:
ods graphics on / border=off;
title "Histogram";
proc univariate data=sashelp.cars ;
var mpg_city;
histogram mpg_city/endpoints=(0 to 65 by 5)
VSCALE=count frontref BARLABEL=COUNT
grid href=17 33 hreflabels="LSL" "USL"
odstitle=title
normal kernel;
run;
As for the other options, you need to understand the difference between Tradiational Graphics and ODS Graphics.
When you use ODS statistical graphics (ODS GRAPHICS ON), you cannot use the options that are specified in the portion of the documentation that says "Options for Traditional Graphics Output". You can use the other options, which includes HREF= and ODSTITLE=.
You cannot use the CHREF= for ODS graphics. ODS graphics uses "styles" to set the attributes of lines, bars, fonts, etc.
Perhaps you specified the syntax incorrectly. The HREF= option is avilable in ODS graphics, as shown in the following example:
ods graphics on / border=off;
title "Histogram";
proc univariate data=sashelp.cars ;
var mpg_city;
histogram mpg_city/endpoints=(0 to 65 by 5)
VSCALE=count frontref BARLABEL=COUNT
grid href=17 33 hreflabels="LSL" "USL"
odstitle=title
normal kernel;
run;
As for the other options, you need to understand the difference between Tradiational Graphics and ODS Graphics.
When you use ODS statistical graphics (ODS GRAPHICS ON), you cannot use the options that are specified in the portion of the documentation that says "Options for Traditional Graphics Output". You can use the other options, which includes HREF= and ODSTITLE=.
You cannot use the CHREF= for ODS graphics. ODS graphics uses "styles" to set the attributes of lines, bars, fonts, etc.
Thank you!!! It is working fine now. But another query came up.
- Since sometime my lsl/usl values goes far beyond histogram and normal curve area,they are not shown in graph screen.how can we increase range of xaxis to cover those href values.
- For previous code,i was getting data in each range in xaxis which helped to understand size of bins and next bin values of histogram.But now i can see skipped values.Could you help me in these matters too 🙂
1. Expand the range of the ENDPOINTS= option so that it includes the LSL and USL. For example:
href=57 73 endpoints=(0 to 75 by 5)
You can read about how to control bin locations in histograms by reading the article "Choosing bins for histograms."
2. SAS provides ODS graphics as a built-in feature of analytical procedures. The options that are surfaced through the procedure syntax are intended to cover about 95% of the typical use cases. For customized graphics, SAS also provided the SGPLOT procedure which enables you to exercise more control over the placement, layout, and attributes of graphical elements such as lines, fonts, and tick marks. If you want to customize a histogram down to the colors of lines and the location of tick marks, I suggest you look into the HISTOGRAM statement for the SGPLOT procedure, as well as other statements that I highlight below:
proc sgplot data=sashelp.cars;
histogram mpg_city / binwidth=10 binstart=5
SCALE=count DATALABEL=COUNT;
density mpg_city / type=normal;
density mpg_city / type=kernel;
refline 57 73 / axis=X label=("LSL" "USL") lineattrs=(color=green);
xaxis values=(0 to 80 by 10);
yaxis grid;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.