Data visualization with SAS programming

Defining a Global Style for a Value in Graphics Template Language

Reply
Occasional Contributor svh
Occasional Contributor
Posts: 16

Defining a Global Style for a Value in Graphics Template Language

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!

Super User
Posts: 13,066

Re: Defining a Global Style for a Value in Graphics Template Language

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.

SAS Employee
Posts: 3

Re: Defining a Global Style for a Value in Graphics Template Language

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.

Ask a Question
Discussion stats
  • 2 replies
  • 106 views
  • 0 likes
  • 3 in conversation