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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.