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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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