Data visualization with SAS programming

PROC Univariate Href not accessible in EG 7.1

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

PROC Univariate Href not accessible in EG 7.1

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.

Accepted Solutions
Solution
‎07-08-2016 01:40 AM
SAS Super FREQ
Posts: 3,623

Re: PROC Univariate Href not accessible in EG 7.1

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


All Replies
Solution
‎07-08-2016 01:40 AM
SAS Super FREQ
Posts: 3,623

Re: PROC Univariate Href not accessible in EG 7.1

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.

Contributor
Posts: 24

Re: PROC Univariate Href not accessible in EG 7.1

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

SAS Super FREQ
Posts: 3,623

Re: PROC Univariate Href not accessible in EG 7.1

[ Edited ]

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;

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 306 views
  • 1 like
  • 2 in conversation