(see code at the bottom)
I build my own custom style ('mystyle') for the creation of graphs, but I don't seem to get my own user-defined style elements to work.
I am using exactly the same syntax as used in the styles.default template source code, but even though my custom style element seems to be defined just fine, it drops following note and indeed uses the default style element (in this case 'GraphTitleText'):
NOTE: The style element 'mygraphtitletext' in the option TEXTATTRS is invalid. The default will be used.
I know there are several other alternatives that I could use (other than defining a custom style), e.g. changing the style element GraphTitleText itself in my custom style, but since I will be using this style in many other graphs and parts of a much more complex program, I really want to get this done in a user-defined style element.
Example code:
proc template;
define style mystyle;
parent=styles.default;
style myGraphFonts /
'myGraphTitleFont' = ("<sans-serif>, <MTsans-serif>",20pt,bold);
style myGraphColors /
'mygtext' = cx00FFFF;
style myGraphTitleText /
font = myGraphFonts('myGraphTitleFont')
color = myGraphColors('mygtext');
end;
run;
ods listing style=mystyle;
proc template;
define statgraph histogram;
begingraph;
entrytitle "title 1 test" / textattrs=myGraphTitleText;
entrytitle "title 2 test" / textattrs=GraphTitleText;
layout overlay;
histogram weight;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class
template=histogram;
run;
Output:
Currently, you cannot create a new style element in your own style -- you can only override the supported style elements. That is why the system generated the log message..
Currently, you cannot create a new style element in your own style -- you can only override the supported style elements. That is why the system generated the log message..
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.
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.
Ready to level-up your skills? Choose your own adventure.