BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Greek
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
esjackso
Quartz | Level 8

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

3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12

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.

esjackso
Quartz | Level 8

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

GraphGuy
Meteorite | Level 14

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 1168 views
  • 7 likes
  • 4 in conversation