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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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