BookmarkSubscribeRSS Feed
IdrissaO
Fluorite | Level 6

Hello, I am trying to use GTL to create a pie chart that presents the reason (reason_call) calls a standard in a health center.the graph is published on a web portal. We would like that when the user moves the cursor on a pie, a tooltip displays the reason for the call (reason_call), the frequency of the reason (number_reason_call) and the proportion (pct_reason_call).
I try to use the DISCRETEATTRMAP statement to make sure that the different reasons retain the same colors over time and regardless of the user. The problem is that the reason_call variable has too many modalities and from one day to another this can vary (the update is done daily). so I have trouble using the DISCRETEATTRMAP statement ca not being able to list all the reasons.
I would like a graph like the one below with the same legend
I manage to create the pie chart. But I have trouble customizing the colors, tips and caption.

 

 

 

IdrissaO_0-1689626741344.png

 

 

Voici le programme

 

data data4pieChart;
	length raison_legend $ 60; /* over-sized, but that is harmless */
	set Mydata;

		raison_legend=strip(reason_call)||" (N = "||strip(number_reason_call)||", p = "||strip(pct_reason_call)|| " %)" ;
		rpt='title="' || trim(left("RaisonLabel")) ||' : ' || '09'x || trim(left(raison_m)) ||
						'0D'x || trim(left("NumberLabel")) ||' : ' || '09'x || trim(left(put(number_reason_call,NumberFmt.))) ||
						'0D'x || trim(left("PctLabel")) ||' : ' || '09'x || trim(left(pct_reason_call)) || " %" ||'"';		
run;



proc template;
	define statgraph piechart;
		begingraph;/*
			discreteattrmap name="piecolors";
				???
			enddiscreteattrmap;*/
			*discreteattrvar attrvar=reason_call_mapped var=reason_call attrmap="piecolors";
			layout region ;
				piechart category=reason_call  response=number_reason_call/ 
					tip=(reason_call number_reason_call pct_reason_call) 
					tipformat =($RaisonFmt. NumberFmt. z5.1)
					tiplabel=("RaisonLabel" "NumberLabel" "PctLabel")							
					datalabelcontent=(category)
					start=0 
					categorydirection=clockwise  
					datalabellocation=callout 
					otherslice=false ;
				
				discretelegend "piechart" / 
					location=outside 
					halign=right 
					valign=center
					border=false  
					across=1;
	
			endlayout;
		endgraph;
	end;
run;

 

1 REPLY 1
JosvanderVelden
SAS Super FREQ

Have a look at the example:

discreteattrmap name="piecolors";
  value "F" / fillattrs=(color=pink);
  value "M" / fillattrs=(color=light_blue);
enddiscreteattrmap;

For documentation see: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p1jzx3nmuupe74n1qy54onbwjoem.htm

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

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
  • 1 reply
  • 460 views
  • 0 likes
  • 2 in conversation