1

Hi I'm trying to create a pie chart that has a lot of slices. For some reason I get an error when running this code. My code

graph pie ccounter if year==1900 & ccounter>100 & labforce==2, over(occ1950)

and I get this error

(note:  areastyle p193pie not found in scheme, default attributes used)
(note:  areastyle p194pie not found in scheme, default attributes used)
(note:  areastyle p195pie not found in scheme, default attributes used)
(note:  areastyle p196pie not found in scheme, default attributes used)
option min() incorrectly specified

Note that the variable occ1950 has more than 100 values. I don't know whether this is what causing the problem.

Extra Information

I use this code to create the variable ccounter

bys mcdstr year occ: gen counter=_n
bys mcdstr year occ: egen ccounter=max(counter)

I used this to calculate the number of people working in each industry by year and location.

Roberto Ferrer
  • 11,024
  • 1
  • 21
  • 23
Rodrigo
  • 69
  • 5
  • 14
  • The first four lines are notes and do not seem to be stopping Stata. The fifth line is what I'd look into, but nowhere in your posted code do I see the `min()` option. You are probably leaving out relevant code. – Roberto Ferrer Nov 07 '14 at 15:31
  • You are correct that the 5th line of the error is whats stopping STATA. I don't know where the min is coming from. Its not even a option in graph command –  Rodrigo Nov 07 '14 at 15:35
  • Can you show us more code? – Roberto Ferrer Nov 07 '14 at 15:36
  • See the edited question. Other than the code for the pie chart, this is the only additional code used in the creation of this graph. Thanks –  Rodrigo Nov 07 '14 at 15:52
  • In one sense, you have probably found a bug in Stata. In another sense, the implication is that you are trying to show a pie chart with >196 slices. The legend alone would swamp the graph. You might as well ask for the 100 metres sprint to be run in 1 second. What you ask makes sense logically, not otherwise. – Nick Cox Nov 07 '14 at 15:58
  • I tried reducing the slices by using a if command to chart only values above a specific values. However I get the same error –  Rodrigo Nov 07 '14 at 16:04
  • Please see http://stackoverflow.com/help/mcve – Nick Cox Nov 07 '14 at 16:12
  • I too think the fact that I am trying to create a pie chart with lot slices is somehow creating a problem –  Rodrigo Nov 12 '14 at 21:35

1 Answers1

0

The problem lies in that the variable occ1950 has too much unique values. Let us examine the problem using a CSV dataset of only 40 countries.

country,fdi
Afghanistan,141.391
Algeria,541.478
Angola,238.637
Antigua and Barbuda,1.653
Argentina,205.691
Bahamas,21.927
Bahrain,1.317
Bangladesh,50.298
Barbados,2.816
"Bolivia, Plurinational State of",41.572
Botswana,87.649
Brazil,455.5649999999999
British Virgin Islands,12387.568
Brunei Darussalam,21.02
Cambodia,672.6800000000001
Cameroon,30.159
Cape Verde,3.783
Cayman Islands,15323.116
Chile,53.149
Colombia,49.047
Congo,112.104
"Congo, Democratic Rep. of",302.505
Costa Rica,.826
Côte d' Ivoire,27.099
Dominican Republic,.112
Ecuador,93.673
Egypt,191.59
Equatorial Guinea,80.21700000000001
Eritrea,16.269
Ethiopia,205.824
Fiji,38.742
Gabon,76.66500000000001
Ghana,129.068
Guinea,97.413
Guyana,79.899
Honduras,2.6
"Hong Kong, China",124987.422
India,291.567
Indonesia,850.0709999999999
"Iran, Islamic Republic of",480.71

After loading this into Stata 14, we can observe that

graph pie fdi, over(country)

produces the error: option min() incorrectly specified.

If we now reduce the dataset to simply 30 countries by: drop _n > 30. We would be able to get a pie chart.

This suggests that you should collapse your data, take the n categories with the largest ccounter and then classify the other classes as "other".

The magic number is 36. So you can have at most 36 unique categories in your pie chart.

Snowflake
  • 2,869
  • 3
  • 22
  • 44