BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sms39
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

 

 

proc sgrender template=SASStudio.Pie data=DataSet;

format Screening_age age_grp. ;


run;

 

if the format isn't permanently associated with the variable.

View solution in original post

5 REPLIES 5
Reeza
Super User

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!


 

sms39
Fluorite | Level 6

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;

Reeza
Super User
You didn't actually apply the format to the SASStudio.Pie data set or at least not shown. Make sure to apply it to that data set.

One way, I don't recommend is as follows:

data sasstudio.pie;
set sasstudio.pie;
format screening_age ageGrp.;
run;

*now have proc template and SGRENDER code;
ballardw
Super User

 

 

proc sgrender template=SASStudio.Pie data=DataSet;

format Screening_age age_grp. ;


run;

 

if the format isn't permanently associated with the variable.

sms39
Fluorite | Level 6
Brilliant! Thank you so much!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 5 replies
  • 966 views
  • 4 likes
  • 3 in conversation