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
Don't you want to sum the number of subjects?
Thanks, I realised I actually need to use SUMVAR. So I finally got it working, thanks
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.