Hi I am using below codes to make a histogram
proc univariate data=filename noprint;
histogram VAR1 ;
run;
I am getting histogram in the output but with Percentage and I want with Frequency count. Could anybody please help me on the same.
I'm not seeing an option in PROC UNIVARIATE, but SGPLOT HISTOGRAM statement has a SCALE=Count option.
Proc SGPLOT data=SASHELP.class;
hisotgram age / scale = count;
run;
The documentation for the HISTOGRAM statement in PROC UNIVARIATE shows that you can use
VSCALE=COUNT
Other options are VSCALE=PERCENT (the default) and VSCALE=PROPORTION.
In regards to the frequency count variable, is there anyway to format that variable? (eg comma format?)
That's an interesting question. I think for large samples, most people switch to PERCENT as a scale instead of COUNT.
I suppose you could write the binned counts to a data set and then use a vertical bar chart:
data Have;
do i = 1 to 1e6;
x = rand("Normal", 10, 2);
output;
end;
run;
Proc univariate data=Have noprint;
var x;
histogram x / VSCALE=COUNT outhist=Want;
run;
proc sgplot data=Want;
format _COUNT_ comma7.; /* apply COMMA format */
vbarbasic _MIDPT_ / response=_COUNT_;
xaxis type=linear values=(0 to 20 by 2);
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.