BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NataljaK
Obsidian | Level 7

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.

 

2022-04-13_8-33-00.png

 

Thank you in advance,

Natalja

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

 

2022-04-13_8-28-57.png

View solution in original post

7 REPLIES 7
Rick_SAS
SAS Super FREQ

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?

NataljaK
Obsidian | Level 7

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

Rick_SAS
SAS Super FREQ

Are you saying that you want to change the font (family, size, color,....) of the text in the legend?

NataljaK
Obsidian | Level 7

Yes, I am.  

There is no problem with title of legend, the problem is with others elements there .

 

Rick_SAS
SAS Super FREQ

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.

 

2022-04-13_8-28-57.png

NataljaK
Obsidian | Level 7

Thank you! It works nicely!

Rick_SAS
SAS Super FREQ

Please mark the correct response as The Answer. This will help others to find the correct answer in the future.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 534 views
  • 1 like
  • 2 in conversation