Hi all
How can I get y scale as density for a histogram?
The histogram statement with proc univariate and proc sgplot support count, proportion and percentage but not density. It seems scale=density is available with proc sgplot, but it does not work with SAS On Demand for Academics.
I tried following codes in the PRoC Step.
proc univariate;
var y;
histogram y/yscale=density;
run;
proc sgplot;
histogram y/ scale=density;
run;
Appreciate an answer.
S_pera
Hello,
To my knowledge, nor PROC UNIVARIATE, nor PROC SGPLOT have a SCALE=DENSITY on the HISTOGRAM statement.
At least not in SAS 9.4 M7 (maybe in VIYA?).
But PROC TEMPLATE can be used :
proc template;
define statgraph histogram;
begingraph;
entrytitle "Histogram of Vehicle Weights";
layout overlay /
xaxisopts=(label="Vehicle Weight (LBS)")
yaxisopts=(griddisplay=on);
histogram weight / SCALE=DENSITY ;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=histogram;
run;
/* end of program */
Koen
Hello,
To my knowledge, nor PROC UNIVARIATE, nor PROC SGPLOT have a SCALE=DENSITY on the HISTOGRAM statement.
At least not in SAS 9.4 M7 (maybe in VIYA?).
But PROC TEMPLATE can be used :
proc template;
define statgraph histogram;
begingraph;
entrytitle "Histogram of Vehicle Weights";
layout overlay /
xaxisopts=(label="Vehicle Weight (LBS)")
yaxisopts=(griddisplay=on);
histogram weight / SCALE=DENSITY ;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=histogram;
run;
/* end of program */
Koen
Dear Koen
Thank you very much for the solution. But I thought we could think of an easier code. Hope we will have the density option added to the histogram statement of PROC Univariate and/or PROC SGPLOT. In fact R is giving this with just
> hist(x,freq=F)
Anyway, the solution is highly appreciated.
S_pera
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.