BookmarkSubscribeRSS Feed
DavidPhillips2
Rhodochrosite | Level 12

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;

3 REPLIES 3
DavidPhillips2
Rhodochrosite | Level 12

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.

DavidPhillips2
Rhodochrosite | Level 12

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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 2264 views
  • 0 likes
  • 1 in conversation