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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 670 views
  • 0 likes
  • 3 in conversation