Hi. I have been user of SAS EG for a long time and I use ODS Graphics Designer for creating graphs.
I experience the problem with the legend - I can't find how to change the style of values in the legend.
It is possible to change the style of the lable, but not of the values.
Thank you in advance,
Natalja
Unfortunately, you cannot change those attributes by using the dialog boxes.
The ODS Graphics Designer creates Graph Template Language (GTL) statements and renders those statements. If you want to make that change, you will have to modify the GTL statements:
1. In ODS Graphics Designer, click View-->Code. A window will appear that has the GTL statements that are used to create your graph. The code will look something like this:
proc template;
define statgraph sgdesign;
dynamic _DATE _CLOSE _STOCK;
begingraph / designwidth=640 designheight=431;
entrytitle halign=center 'My Graph Title';
layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
layout overlay;
seriesplot x=_DATE y=_CLOSE / group=_STOCK name='series' clusterwidth=0.5 connectorder=xaxis grouporder=data;
discretelegend 'series' / opaque=true backgroundcolor=CXFFFFFF border=true halign=center
valign=bottom title='SUUNAD' displayclipped=true down=1 order=columnmajor location=outside;
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=WORK.STOCKS template=sgdesign;
dynamic _DATE="DATE" _CLOSE="CLOSE" _STOCK="STOCK";
run;
2. To make your change, first copy this code. Click inside the code window. Then click Edit->Select All followed by Edit->Copy.
3. Paste these statements into a SAS programming window in EG.
4. On the DISCRETELEGEND statement, add the following option:
discretelegend 'series' / opaque=true backgroundcolor=CXFFFFFF border=true halign=center
valign=bottom title='SUUNAD' displayclipped=true down=1 order=columnmajor location=outside
valueattrs=(Family='Arial' Size=8 Style=Italic Weight=Bold) autoitemsize=TRUE /* <== ADD THIS LINE */
;
5. You can change the values of the options to configure the legend.
6. To render the graph, submit the modified program.
To enable us to help you, please do the following:
1. Post a picture of the current graph.
2. Explain what you want to change. For example, "The legend currently shows a blue circle for males and a red circle for females. I want the legend to show a green plus sign (+) for males and a brown triangle for females."
Also, do you want the change only in the legend, or do you also want to see the change in the graph?
Hi,
I am not programmer and I do not use coding widly.
I create graphics by means of ODS Graphics Designer from SAS EG.
I would like to change the style of values in graph's legend the way as it is available for the legend's title, not by changing the code.
It is seen in the attached document, that ODS Graphics Designer does not have such an opportunity.
Kind regards
Natalja
Are you saying that you want to change the font (family, size, color,....) of the text in the legend?
Yes, I am.
There is no problem with title of legend, the problem is with others elements there .
Unfortunately, you cannot change those attributes by using the dialog boxes.
The ODS Graphics Designer creates Graph Template Language (GTL) statements and renders those statements. If you want to make that change, you will have to modify the GTL statements:
1. In ODS Graphics Designer, click View-->Code. A window will appear that has the GTL statements that are used to create your graph. The code will look something like this:
proc template;
define statgraph sgdesign;
dynamic _DATE _CLOSE _STOCK;
begingraph / designwidth=640 designheight=431;
entrytitle halign=center 'My Graph Title';
layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
layout overlay;
seriesplot x=_DATE y=_CLOSE / group=_STOCK name='series' clusterwidth=0.5 connectorder=xaxis grouporder=data;
discretelegend 'series' / opaque=true backgroundcolor=CXFFFFFF border=true halign=center
valign=bottom title='SUUNAD' displayclipped=true down=1 order=columnmajor location=outside;
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=WORK.STOCKS template=sgdesign;
dynamic _DATE="DATE" _CLOSE="CLOSE" _STOCK="STOCK";
run;
2. To make your change, first copy this code. Click inside the code window. Then click Edit->Select All followed by Edit->Copy.
3. Paste these statements into a SAS programming window in EG.
4. On the DISCRETELEGEND statement, add the following option:
discretelegend 'series' / opaque=true backgroundcolor=CXFFFFFF border=true halign=center
valign=bottom title='SUUNAD' displayclipped=true down=1 order=columnmajor location=outside
valueattrs=(Family='Arial' Size=8 Style=Italic Weight=Bold) autoitemsize=TRUE /* <== ADD THIS LINE */
;
5. You can change the values of the options to configure the legend.
6. To render the graph, submit the modified program.
Thank you! It works nicely!
Please mark the correct response as The Answer. This will help others to find the correct answer in the future.
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.