Data visualization with SAS programming

Legend is supressed

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Legend is supressed

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?


Accepted Solutions
Solution
‎07-18-2012 01:20 PM
SAS Employee
Posts: 977

Re: Legend is supressed

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


All Replies
SAS Employee
Posts: 977

Re: Legend is supressed

Does your SAS log mention anything about the legend?

Occasional Contributor
Posts: 13

Re: Legend is supressed

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.

Solution
‎07-18-2012 01:20 PM
SAS Employee
Posts: 977

Re: Legend is supressed

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:

Occasional Contributor
Posts: 13

Re: Legend is supressed

Hi Robert,

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

Contributor
Posts: 66

Re: Legend is supressed

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?

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 784 views
  • 0 likes
  • 3 in conversation