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;
Just found this.
24877 - Format percentage values on a pie chart with PROC GCHART
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.
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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.