Data visualization with SAS programming

Pie Gchart Percent Rounding

Reply
Super Contributor
Posts: 465

Pie Gchart Percent Rounding

Is there a way to format percent in proc gchart with a pie chart in SAS 9.2?  All of the examples that I see online do not use a format statement. My format statement does not seem to take effect.

proc gchart data=enrollment;                                                                                                 

    pie col1 /                                                                                                 

    sumvar=col2

    legend=legend1 percent=outside discrete;

    format col1 percent10.;

  run;                                                                                                                              

  quit;

Super Contributor
Posts: 465

Re: Pie Gchart Percent Rounding

Super Contributor
Posts: 465

Re: Pie Gchart Percent Rounding

The example works if I run just the example however I have a second format clause for using a value clause.  It seems that with them both the example breaks.

Super Contributor
Posts: 465

Re: Pie Gchart Percent Rounding

For example:

proc format;

   value Rankinga

   1 = 'Undergraduate'

   2 = 'Graduate'

   3 = 'Professional Practice (First professional)'

   4 = 'Undergraduate Non-degree Seeking'

   5 = 'Graduate Non-degree Seeking';

run;

proc sql noprint;

CREATE TABLE testTable(

        Units int,

        student_level int

   );

  INSERT INTO TestTable (Units, student_level)

  VALUES (11, 1);

  INSERT INTO TestTable (Units, student_level)

  VALUES (23, 1);

  INSERT INTO TestTable (Units, student_level)

  VALUES (4, 1);

  INSERT INTO TestTable (Units, student_level)

  VALUES (43, 2);

  INSERT INTO TestTable (Units, student_level)

  VALUES (54, 2);

  INSERT INTO TestTable (Units, student_level)

  VALUES (28, 2);

  INSERT INTO TestTable (Units, student_level)

  VALUES (38, 3);

  INSERT INTO TestTable (Units, student_level)

  VALUES (11, 3);

  INSERT INTO TestTable (Units, student_level)

  VALUES (4, 3);

  INSERT INTO TestTable (Units, student_level)

  VALUES (57, 4);

  INSERT INTO TestTable (Units, student_level)

  VALUES (48, 4);

  INSERT INTO TestTable (Units, student_level)

  VALUES (99, 4);

  INSERT INTO TestTable (Units, student_level)

  VALUES (110, 5);

  INSERT INTO TestTable (Units, student_level)

  VALUES (243, 5);

  INSERT INTO TestTable (Units, student_level)

  VALUES (334, 5);

  quit;

%Stpbegin;

proc format;

   picture pctfmt (round) 0-high='000%';

run;

title1 &titleText;                                                                                                    

  proc gchart data=testTable;                                                                                                      

    pie student_level /                                                                                                      

   sumvar=units

      legend=legend1 percent=outside discrete;

   format units pctfmt.;

   format student_level Rankinga.;

  run;                                                                                                                                   

quit;

%Stpend;

piechart not formated.png

Ask a Question
Discussion stats
  • 3 replies
  • 350 views
  • 0 likes
  • 1 in conversation