BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Dear all, 

suppose I have a dataset that looks like this, and I wish to create a pie chart with sub categories  as shown below

proc format;
value $ level "1"="level1"
             "2"="level2"
			 "3"="level3"
			 "5"="level5"
			 "6"="level6"
			 "7"="level7"
;
run;


data have; infile datalines; format level $level.; input answers $4. level $2. num_of_subjects ; datalines; No 1 100 yes 1 50 No 2 80 yes 2 150 yes 3 16 No 3 2 yes 5 45 No 6 180 yes 6 200 No 7 55 ; run; legend1 label=none shape=bar(4,1.5) position=(top left) offset=(5,) across=2 mode=share; proc gchart data=have ; pie level / detail=answers other=0 midpoints= 'level1' 'level1' 'level2' 'level2' 'level3' 'level3' 'level5' 'level6' 'level6' 'level7' radius=35 angle=90 slice= none noheading coutline=black legend=legend1; run; quit;

how do I include the variable num_of_subjects in the code to get the exact proportion of each slices. I also wish to include the value of num_of_subjects in each subgroup/slice. Using SUMVAR sums up the variables and that is not what I want.

 

Thanks for any help 

 

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Don't you want to sum the number of subjects?

Anita_n
Pyrite | Level 9

Thanks, I realised I actually need to use SUMVAR. So I finally got it working, thanks

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 383 views
  • 0 likes
  • 2 in conversation