- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc univariate data=sashelp.heart;
var weight;
histogram weight/vscale=count;
histogram weight/vscale=percent;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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