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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 798 views
  • 0 likes
  • 2 in conversation