BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi All,

I am creating a legend with PROC GCHART VAR3D,  but not sure why it is not created into the final output. Please note that the ODS destination is PDF.

Is there any chance of legend getting suppressed because of any other option in the code?

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

Patternid simply colors the bars - if you want a legend, you'll need to use the subgroup= option rather than patternid= option (I have never really found a good use for 'patternid' - if I want bar segments to be colored I always use the subgroup option).  Here is an example:

legend1 position=bottom;

proc gchart data=sashelp.class;
vbar sex / type=sum sumvar=weight patternid=midpoint legend=legend1;
run;

proc gchart data=sashelp.class;
vbar sex / type=sum sumvar=weight subgroup=sex legend=legend1;
run;

This is mentioned in the gchart documentation:

http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gchart-bar.htm

  • The PATTERNID= option is set to any value other than
    SUBGROUP; that is, the value of PATTERNID= is BY or GROUP or
    MIDPOINT.

      To create a legend based on the chart midpoints
     instead of the subgroups, use the chart variable as the subgroup variable:

View solution in original post

5 REPLIES 5
GraphGuy
Meteorite | Level 14

Does your SAS log mention anything about the legend?

alwaz_searching
Calcite | Level 5

Hi Robert,

Below is the reference code. The log is having no info regarding the legend.

goptions ftext   = "Albany AMT"

         ftitle  = "Albany AMT"

         htext   = 12pt

         vsize   = 6.00

         hsize   = 8.42

         vorigin = 1.00

         rotate  = portrait

         ; 

title1 'Title';

footnote;

pattern1 v=s c=yellow;

pattern2 v=s c=red;

pattern3 v=s c=green;

/* Define legend characteristics */

legend1  label=(height=1 'Category')  value=(tick=1 j=c "DEPARTMENT" tick=2 j=c "RESULT" tick=3 j=c "COMMENT")

         across=3 down=1  position = bottiom mode=reserve ;

axis1 label=('Value') order= (0 to 30 by 5) minor=none   ;

axis2 label=none value=none;

axis3 label=none  value=(a=90) ;

PROC GCHART DATA=ssu_g_t;

   VBAR3D cat /

       SUMVAR=count

       GROUP=date

       LEGEND = LEGEND1

       SHAPE=BLOCK     

       COUTLINE=BLACK

       RAXIS=AXIS1

       MAXIS=AXIS2

       GAXIS=AXIS3

       OUTSIDE=SUM

       PATTERNID=MIDPOINT

       AUTOREF CREF=gray7a

      

;

run;

quit;

Please not that cat is a char variable and cnt is the total count per category value and date is the x axis (month/year wise).

I am getting below two warning in the log (and also inside=sum / outside= sum option also not working for PROC GCHART VAR3D):

 

WARNING: The intervals on the axis labeled date are not evenly spaced.

WARNING: The VBAR/VBAR3D chart for cat could not be labeled because the labels are wider than the bars.

GraphGuy
Meteorite | Level 14

Patternid simply colors the bars - if you want a legend, you'll need to use the subgroup= option rather than patternid= option (I have never really found a good use for 'patternid' - if I want bar segments to be colored I always use the subgroup option).  Here is an example:

legend1 position=bottom;

proc gchart data=sashelp.class;
vbar sex / type=sum sumvar=weight patternid=midpoint legend=legend1;
run;

proc gchart data=sashelp.class;
vbar sex / type=sum sumvar=weight subgroup=sex legend=legend1;
run;

This is mentioned in the gchart documentation:

http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gchart-bar.htm

  • The PATTERNID= option is set to any value other than
    SUBGROUP; that is, the value of PATTERNID= is BY or GROUP or
    MIDPOINT.

      To create a legend based on the chart midpoints
     instead of the subgroups, use the chart variable as the subgroup variable:

alwaz_searching
Calcite | Level 5

Hi Robert,

Thank you!!! It worked out!!! Smiley Happy

Dorota_Jarosz
Obsidian | Level 7

You need to be more specific about your syntax. Are you creating a legend statement and referencing it in the proc gchart?  Did you try to change the output to html or rtf or other format?

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