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";
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.