BookmarkSubscribeRSS Feed
deega
Quartz | Level 8

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.

 

5 REPLIES 5
Reeza
Super User

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;

Rick_SAS
SAS Super FREQ

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.

arcacha
Fluorite | Level 6

In regards to the frequency count variable, is there anyway to format that variable? (eg comma format?)

Rick_SAS
SAS Super FREQ

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;
arcacha
Fluorite | Level 6
That's perfect - exactly what I was look for! Pity PROC UNIVARIATE doesn't have the same functionality.

Thanks again!

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 30173 views
  • 7 likes
  • 4 in conversation