BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Golf
Pyrite | Level 9

Hello,

  I have one categorical with 5 values: 1, 2, 3, 4, 5.   The data is 50 observations.

I'd like to create pie chart showing in frequency by using proc schart as follow:

proc gchart data=softdrink_new;
format X X_value_label.;
pie X / sumvar=X ;
run;

But the result of pie chart show the number which are not frequency of each category and label only on piece of the pie chart.

How can I correct this problem?   Moreover, how to show the number in percentage in separate and the same pie chart?

Thank You 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Golf 

 

Would this code meet your needs?

data softdrink_new;
	input X @@;
	datalines;
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
1 1 1 1 1 1 1 1 4 2 2 2 3 4 5 1 2 3 4 5 1 2 3 4 5
;
run;

proc format;
	value X_value_label 1="label1" 2="label2" 3="label3" 4="label4" 5="label5";
run;


/*Only frequencies*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / type=freq discrete; 
run;

/*Only percents*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / type=percent discrete; 
run;

/*Frequencies + percent*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / percent=outside discrete; 
run;

Best,

View solution in original post

3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @Golf 

 

Would this code meet your needs?

data softdrink_new;
	input X @@;
	datalines;
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
1 1 1 1 1 1 1 1 4 2 2 2 3 4 5 1 2 3 4 5 1 2 3 4 5
;
run;

proc format;
	value X_value_label 1="label1" 2="label2" 3="label3" 4="label4" 5="label5";
run;


/*Only frequencies*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / type=freq discrete; 
run;

/*Only percents*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / type=percent discrete; 
run;

/*Frequencies + percent*/
proc gchart data=softdrink_new;
	format X  X_value_label.;
	pie X / percent=outside discrete; 
run;

Best,

Golf
Pyrite | Level 9
Thank you so much.
ed_sas_member
Meteorite | Level 14
You're welcome @Golf !

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 592 views
  • 1 like
  • 2 in conversation