BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gauravp1993
Obsidian | Level 7
i tried to create histogram using proc univariate and planned to add LSL /USL using href option.I wrote the following code:

title "Histogram";
proc univariate data=limits ;
var test_value;
histogram test_value/endpoints=(0 to 10 by 1)
VSCALE=count frontref BARLABEL=COUNT
grid
normal kernel;
ods select all;
ods graphics on/ width=1300PX HEIGHT=650PX border=off;
run;

but when i tried to include href in the code as guided in sas documents, it was not available whereas vref option was available.Also options for modifying href like chref and hreflabel was available.Please help me for this or guide me any alternative to it within proc univariate.
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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.

gauravp1993
Obsidian | Level 7

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 🙂2016-07-08 07_42_31-Project - SAS Enterprise Guide.png  

Rick_SAS
SAS Super FREQ

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;

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1352 views
  • 1 like
  • 2 in conversation