Hi all,
I am trying to create a pie chart with the ages of a group of study participants, but am struggling to divide the data points into specific categories within the chart. I would like to divide the group into ages <30, 30-59, and >59, but can't seem to group the data points into these 3 categories when I produce the pie chart. Is there a way to specify these groups in the proc template code, or do I need to create groups in the data set before trying to make the chart?
thank you!
proc sgrender template=SASStudio.Pie data=DataSet;
format Screening_age age_grp. ;
run;
if the format isn't permanently associated with the variable.
Use a FORMAT in the code. If the data is grouped by the format it should work but it may also depend on which PROC you're using, which you haven't specified.
@sms39 wrote:
Hi all,
I am trying to create a pie chart with the ages of a group of study participants, but am struggling to divide the data points into specific categories within the chart. I would like to divide the group into ages <30, 30-59, and >59, but can't seem to group the data points into these 3 categories when I produce the pie chart. Is there a way to specify these groups in the proc template code, or do I need to create groups in the data set before trying to make the chart?
thank you!
I've been able to sub-categorize the ages, but can't seem to get the pie chart to utilize the new groupings. I assume there is something I need to specify along the bolded line of code, but I can't seem to get it right. Any suggestions would be appreciated
/* new age groups*/
proc format;
value AgeGrp 1-30 ='<30'
value AgeGrp 30-59 = '30-59'
value AgeGrp 60-100 = '>60';
run;
proc freq data=DataSet;
format Screening_AGE AgeGrp.;
Table Screening_AGE;
Run;
/* Define Pie template */
proc template;
define statgraph SASStudio.Pie;
begingraph;
layout region;
piechart category= Screening_AGE /;
endlayout;
endgraph;
end;
run;
ods graphics / reset width=6.4in height=4.8in imagemap;
proc sgrender template=SASStudio.Pie data=DataSet;
run;
ods graphics / reset;
proc sgrender template=SASStudio.Pie data=DataSet;
format Screening_age age_grp. ;
run;
if the format isn't permanently associated with the variable.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.