Data visualization with SAS programming

Gchart showing five most frequent values only

Reply
Contributor
Posts: 20

Gchart showing five most frequent values only

Hi,

How can I use proc gchart display the five most frequent values in a data set? From running proc freq, I know that these are the five most frequent values:

Value Count
-1000.00 157
-2000.00 156
-3000.00 155
-4000.00 120
-10000.00 110

I have searched the forums and the web for help but cannot seem to come up with the right combination of search terms to find an answer so I hope that someone in here can help me.

Thanks,

Helle
SAS Employee
Posts: 963

Re: Gchart showing five most frequent values only

Something like this?

data foo;
input value count;
datalines;
-1000.00 157
-2000.00 156
-3000.00 155
-4000.00 120
-10000.00 110
;
run;
proc gchart data=foo;
vbar value / discrete type=sum sumvar=count;
run;
SAS Super FREQ
Posts: 864

Re: Gchart showing five most frequent values only

Hey,

The way I would approach this is to use PROC SUMMARY to summarize the data based on frequency, use PROC SORT to sort the result by descending frequency, and use PROC GCHART to display the first N bars that I want to see (using OBS=). The simple example below charts the 3 most frequent values.

[pre]
proc summary data=sashelp.class nway;
class age;
output out=agefreq;
run;

proc sort data=agefreq; by descending _freq_; run;

proc gchart data=agefreq (obs=3);
vbar age / sumvar=_freq_ outside=sum discrete;
run;
[/pre]

Hope this helps!
Dan
Contributor
Posts: 20

Re: Gchart showing five most frequent values only

Hi Dan and Robert,

Thanks a lot for your suggetions - they both do the job :-)

Best regards,

Helle
Super Contributor
Posts: 291

Re: Gchart showing five most frequent values only

Or, if you have SAS/QC, use

proc pareto.
hbar variable/maxncat=5;
run;
Post a Question
Discussion Stats
  • 4 replies
  • 194 views
  • 0 likes
  • 4 in conversation