Data visualization with SAS programming

Proc Gchart: Pie error

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

Proc Gchart: Pie error

Hello,

I just spotted an error, which I don't know how to solve programmatically. I have the frequency table below and I wanted to create a pie for the major 5 car manufacturers and group the rest in the category named "other." I used the other=5 option but the resulting pie is not correct. The "other" category should be 24% and not 16%. By looking at the log, I realized that SAS ignored any observation that had a relative frequency less than 1%. Do you know why is it doing that?

data cars;

input make $ count percent;

datalines;

PLYMOUTH    1    0.0530786

SCION        1    0.0530786

SUBARU        1    0.0530786

VOLKSWAGEN    1    0.0530786

INFINITI    2    0.1061571

LINCOLN        2    0.1061571

ISUZU        4    0.2123142

OLDSMOBILE    7    0.3715499

GMC            14    0.7430998

HONDA        14    0.7430998

BUICK        16    0.8492569

MERCURY        19    1.0084926

MITSUBISHI    26    1.3800425

MAZDA        28    1.4861996

SUZUKI        30    1.5923567

TOYOTA        30    1.5923567

JEEP        38    2.0169851

HYUNDAI        47    2.4946921

SATURN        52    2.7600849

NISSAN        53    2.8131635

KIA            60    3.1847134

PONTIAC        122    6.4755839

CHRYSLER    261    13.8535032

FORD        283    15.0212314

DODGE        320    16.985138

CHEVROLET    452    23.9915074

run;

ods html;

proc gchart data=cars;

pie make / freq=percent other=5;

run;

ods html close;


Accepted Solutions
Solution
‎10-04-2013 02:34 PM
Super Contributor
Posts: 333

Re: Proc Gchart: Pie error

This revised code probably gets you closer to what you are looking for. Probably will want to clean it up some more but thought this would provide a starting place.

ods html;

proc gchart data=cars;

pie make / freq=count other=5 percent=outside ;

run;

ods html close;

EJ

View solution in original post


All Replies
Valued Guide
Posts: 2,111

Re: Proc Gchart: Pie error

SAS is working as intended.  RTFM (bold added):

FREQ=numeric-variable

specifies a variable whose values weight the contribution of each observation in the computation of the chart statistic. Each observation is counted the number of times specified by the value of numeric-variable for that observation. If the value of numeric-variable is missing, 0, or negative, the observation is not used in the statistic calculation. Non-integer values of numeric-variable are truncated to integers.

Solution
‎10-04-2013 02:34 PM
Super Contributor
Posts: 333

Re: Proc Gchart: Pie error

This revised code probably gets you closer to what you are looking for. Probably will want to clean it up some more but thought this would provide a starting place.

ods html;

proc gchart data=cars;

pie make / freq=count other=5 percent=outside ;

run;

ods html close;

EJ

SAS Employee
Posts: 967

Re: Proc Gchart: Pie error

Since you have pre-calculated your percents in the data set, you could just let gchart sum up those pre-calculated values in the pie slices:

proc gchart data=cars;

pie make / type=sum sumvar=percent other=5 noheader;

run;

foo.png

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 361 views
  • 7 likes
  • 4 in conversation