BookmarkSubscribeRSS Feed
dbcrow
Obsidian | Level 7

Hi, SAS Users!  

 

I'm trying to create a tile chart in which the tiles contain both the labels of the group they represent and the percentage that that group is of the total population.  Here's some code:  


*Figure 4:  Tile Chart w/ Relative Sizes of Native American Groups;
data naan_tilechart;
	input class pop total;
cards;
1 164038 1087183
2 486212 1087183
3 228101 1087183
4 208832 1087183
;
run;



data naan_tilechart;
	set naan_tilechart;
	per = pop/total;
	format per percent9.1;
run;

proc format;
	label class = "Race/Ethnicity Category"
		pop = "Count";
	value class
		1="1-Race, Non-Hisp"
		2="1-Race, Hisp"
		3=">1-Race, Non-Hisp"
		4=">1-Race, Hisp"
		;
run;


title1 "Native American/Alaskan Natives";
title2 "By Race and Hispanic Origin";
proc gtile data=naan_tilechart;
 	TILE pop
 	tileby=(class);
	format class class.;
run;

And here's the resulting tile chart:  

 

image.png

What I would like to do is (1) insert the percentages for each tile and (2) eliminate the--is it an axis label?--"class" above the upper left-hand corner of the chart.  

 

Thanks,

David

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

Hello,

 

Create a new variable concatenating percent and class. 

 

data naan_tilechart;
	set naan_tilechart;
	per = pop/total;
	format per percent9.1;
Class_new=cats(put(class,class.),'(',put(per,percent9.1),')');

run;

title1 "Native American/Alaskan Natives";
title2 "By Race and Hispanic Origin";
proc gtile data=naan_tilechart;
 	TILE pop
 	tileby=(class_new);
	format class class.;
label class_new="09"x; /* This will blank the label name*/
run;

Capture.PNG

Thanks,
Suryakiran
dbcrow
Obsidian | Level 7

Thanks, SuryaKiran-

 

Is there no data label option in PROC GTILE? 

 

Also, how would I get the percentage on a separate line?  Your solution is great, but it looks a little cluttered to me.  

 

Thanks for the patience.  

 

Best,

David

dbcrow
Obsidian | Level 7

And one other question (sorry to be such a bother):  how can I export the graph as an image with the title?  

 

Thanks,

David

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1702 views
  • 0 likes
  • 2 in conversation