BookmarkSubscribeRSS Feed
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

Hello,

 

I have been trying to adopt the Graphics Template Language, and I'm used to using the DATTRMAP statement in PROC SGPLOT in examples such as the following to ensure that certain values always have specific styles. 

 

/*--Define attributes map data set--*/
data AttrMap;
  length id value linecolor markercolor $8;
  id='TYPE'; value='PUBLIC'; linecolor='Red';  markercolor='Red'; output;
  id='TYPE'; value='PRIVATE'; linecolor='Green';   markercolor='Green';  output;
  id='TYPE'; value='UD VALUE'; linecolor='Blue'; markercolor='Blue';output;
  run;



/*plot of in-state tuition at public schools*/
filename graphout 'tuition.png';
goptions reset=all device=png gsfname=graphout;
ods graphics /  width=5in height=3in antialiasmax=1100  ;
PROC SGPLOT DATA=AI.COSTS DATTRMAP=ATTRMAP;
WHERE TYPE IN ('PUBLIC' 'UD VALUE') AND COST_ITEM='In_Tuition';
SERIES X=YEAR Y = MEAN / group=type lineattrs=(thickness=3)attrid=Type markers;
LABEL cost_item = 'In-State Tuition';
FORMAT mean dollar10.;
yaxis values=(0 to 12000 by 1000) label='In-State Tuition';
TITLE 'Average In-State Tuition for ASQ Public Schools';
title2 'With Reference Line for University of Delaware';
run;
TITLE;
quit;

Can someone point me to a similar resource that describes how to do this with PROC TEMPLATE in the graphics template language?

 

I have been using the DISCRETATTRMAP statement in PROC TEMPLATE (as in the following example), but I'm defining it each time I make a template. Is there a more efficient way to apply this style across multiple templates?

 

 discreteattrmap name="munchkin" / ignorecase=true ;
     value "UD Value" / markerattrs=(color=black symbol=circlefilled size=6pt) 
						   lineattrs=(color=blue thickness=3);
		 value "Benchmark Avg." / markerattrs=(color=black symbol=circlefilled size=6pt)
							lineattrs=(color=red thickness=3);
	   enddiscreteattrmap;

	   discreteattrvar attrvar=groupmarkers var=college attrmap="munchkin";

Thank you!

2 REPLIES 2
ballardw
Super User

Put the characteristics into a data set. Reference the data set in SGRENDER with the DATTRMAP= option. Reference the attribute id with DATTRVAR statement for the group variables. The variable(s) in the dattrvar statement either match the variable used in the template or use dynamic variables.

 

The online reference for DATTRVAR in the SGRENDER documentation shows an example. Note that the template does not have to reference the attribute map, sgrender makes the connection as long as the variables match.

sdengland
SAS Employee

To add to ballardw's suggestion, you can also find information about how to store a discrete attribute map in a SAS data set and how to use it with GTL in SAS® 9.4 Graph Template Language: User's Guide.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 914 views
  • 0 likes
  • 3 in conversation