Data visualization with SAS programming

barchart not using fillpattern

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

barchart not using fillpattern

I have a bar chart using GTL and its obviously picking up the colour but not the fill pattern.

code and output attached

Attachment
Attachment

Accepted Solutions
Solution
‎02-20-2014 12:25 PM
SAS Super FREQ
Posts: 1,081

Re: barchart not using fillpattern

Your fill colors and contrast colors (for pattern) are the same.  So. yoiu cannot see the pattern.  I made your fill patterns of a lighter shade.  I also removed your macro variables and changed many settings so the program will work for me.   In such cases, it helps if you post code that can be run by others without need for your special data or marco vars.

Pattern.png

%macro odsstyle;
proc template;
Define style styles.lineplot;
  Parent=styles.rtf;
  class graph / attrpriority='none';

  Style graphdata1 from graphdata1 / MarkerSymbol="circlefilled"  Linestyle=1
              Color=gray Contrastcolor=black  fillpattern = "E" ;
  Style graphdata2 from graphdata2 / MarkerSymbol="trianglefilled" Linestyle=4
              Color=lightblue   Contrastcolor=blue   fillpattern = "S" ;
  Style graphdata3 from graphdata3 / MarkerSymbol="squarefilled" Linestyle=2
              Color=lightblue     Contrastcolor=blue  fillpattern = "R1" ;  
  Style graphdata4 from graphdata4 / MarkerSymbol="diamondfilled"  Linestyle=42
              Color=lightblue Contrastcolor=blue  fillpattern = "L1" ;
  Style graphdata5 from graphdata5 / MarkerSymbol="starfilled" Linestyle=22
              Color=lightblue    Contrastcolor=blue   fillpattern = "X1" ;
  Style graphdata6 from graphdata6 / MarkerSymbol="hash" Linestyle=8
              Color=pink   Contrastcolor=red  fillpattern = "R3" ;

  style Table from output /
     background=_undef_
     Rules=groups
     Frame=void
     cellpadding = 1pt
     cellspacing = 0pt
     borderwidth = 0.5pt;
  style header from header /
     background=_undef_;
  style systemfooter from titlesandfooters /
     protectspecialchars=off;
  style rowheader from rowheader /
     background=_undef_;
  style body from document /
    leftmargin   = 1in
    rightmargin  = 1in
    topmargin    = 1in
    bottommargin = 1in;

/*  replace fonts /*/
/*        'TitleFont2'          = ("&FTYPE",&FONT.)*/
/*        'TitleFont'           = ("&FTYPE",&FONT.)*/
/*        'StrongFont'          = ("&FTYPE",&FONT.)*/
/*        'EmphasisFont'        = ("&FTYPE",&FONT.,Italic)*/
/*        'FixedEmphasisFont'   = ("&FTYPE",&FONT.,Italic)*/
/*        'FixedStrongFont'     = ("&FTYPE",&FONT.)*/
/*        'FixedHeadingFont'    = ("&FTYPE",&FONT.)*/
/*        'BatchFixedFont'      = ("&FTYPE",&FONT.)*/
/*        'FixedFont'           = ("&FTYPE",&FONT.)*/
/*        'headingEmphasisFont' = ("&FTYPE",&FONT.,Italic)*/
/*        'headingFont'         = ("&FTYPE",&FONT.)*/
/*        'docFont'             = ("&FTYPE",&FONT.);*/
end;
run;
%mend odsstyle;
%odsstyle;

ods graphics on / width=25cm noborder height=13cm ;
/*ods rtf nogtitle nogfootnote file = "&_outpath\&_filename" style=styles.lineplot;*/
/*ods listing close;*/

proc template; 
define statgraph WATERFALL ; 
   dynamic _x _y _var _label;

  begingraph / designheight = 600 designwidth = 1200 border = false; 

discreteattrvar attrvar=signvar var=_var attrmap="colorbysign"; 
layout overlay /
           yaxisopts=(linearopts=(viewmin=-50 viewmax=50) labelattrs=(size=8 family="Arial"))
              xaxisopts=(display=none );
      barchart x=_x y=_y / group=_var name='b' display=all groupdisplay=cluster;
    discretelegend "b" / title=_label SORTORDER=ASCENDINGFORMATTED ;
       referenceline y=20 / lineattrs=(pattern=4);
       referenceline y=-30 / lineattrs=(pattern=4);
endlayout; 
  endgraph;
end;

ods html close;
ods listing style=styles.lineplot;
proc sgrender data=sashelp.cars template=Waterfall;
/*where STDYPART='B';*/
dynamic _x     = 'origin'
         _y     = 'mpg_city'
   _var   = 'type'
   _label ='Treatment:'
;
run;

View solution in original post


All Replies
Solution
‎02-20-2014 12:25 PM
SAS Super FREQ
Posts: 1,081

Re: barchart not using fillpattern

Your fill colors and contrast colors (for pattern) are the same.  So. yoiu cannot see the pattern.  I made your fill patterns of a lighter shade.  I also removed your macro variables and changed many settings so the program will work for me.   In such cases, it helps if you post code that can be run by others without need for your special data or marco vars.

Pattern.png

%macro odsstyle;
proc template;
Define style styles.lineplot;
  Parent=styles.rtf;
  class graph / attrpriority='none';

  Style graphdata1 from graphdata1 / MarkerSymbol="circlefilled"  Linestyle=1
              Color=gray Contrastcolor=black  fillpattern = "E" ;
  Style graphdata2 from graphdata2 / MarkerSymbol="trianglefilled" Linestyle=4
              Color=lightblue   Contrastcolor=blue   fillpattern = "S" ;
  Style graphdata3 from graphdata3 / MarkerSymbol="squarefilled" Linestyle=2
              Color=lightblue     Contrastcolor=blue  fillpattern = "R1" ;  
  Style graphdata4 from graphdata4 / MarkerSymbol="diamondfilled"  Linestyle=42
              Color=lightblue Contrastcolor=blue  fillpattern = "L1" ;
  Style graphdata5 from graphdata5 / MarkerSymbol="starfilled" Linestyle=22
              Color=lightblue    Contrastcolor=blue   fillpattern = "X1" ;
  Style graphdata6 from graphdata6 / MarkerSymbol="hash" Linestyle=8
              Color=pink   Contrastcolor=red  fillpattern = "R3" ;

  style Table from output /
     background=_undef_
     Rules=groups
     Frame=void
     cellpadding = 1pt
     cellspacing = 0pt
     borderwidth = 0.5pt;
  style header from header /
     background=_undef_;
  style systemfooter from titlesandfooters /
     protectspecialchars=off;
  style rowheader from rowheader /
     background=_undef_;
  style body from document /
    leftmargin   = 1in
    rightmargin  = 1in
    topmargin    = 1in
    bottommargin = 1in;

/*  replace fonts /*/
/*        'TitleFont2'          = ("&FTYPE",&FONT.)*/
/*        'TitleFont'           = ("&FTYPE",&FONT.)*/
/*        'StrongFont'          = ("&FTYPE",&FONT.)*/
/*        'EmphasisFont'        = ("&FTYPE",&FONT.,Italic)*/
/*        'FixedEmphasisFont'   = ("&FTYPE",&FONT.,Italic)*/
/*        'FixedStrongFont'     = ("&FTYPE",&FONT.)*/
/*        'FixedHeadingFont'    = ("&FTYPE",&FONT.)*/
/*        'BatchFixedFont'      = ("&FTYPE",&FONT.)*/
/*        'FixedFont'           = ("&FTYPE",&FONT.)*/
/*        'headingEmphasisFont' = ("&FTYPE",&FONT.,Italic)*/
/*        'headingFont'         = ("&FTYPE",&FONT.)*/
/*        'docFont'             = ("&FTYPE",&FONT.);*/
end;
run;
%mend odsstyle;
%odsstyle;

ods graphics on / width=25cm noborder height=13cm ;
/*ods rtf nogtitle nogfootnote file = "&_outpath\&_filename" style=styles.lineplot;*/
/*ods listing close;*/

proc template; 
define statgraph WATERFALL ; 
   dynamic _x _y _var _label;

  begingraph / designheight = 600 designwidth = 1200 border = false; 

discreteattrvar attrvar=signvar var=_var attrmap="colorbysign"; 
layout overlay /
           yaxisopts=(linearopts=(viewmin=-50 viewmax=50) labelattrs=(size=8 family="Arial"))
              xaxisopts=(display=none );
      barchart x=_x y=_y / group=_var name='b' display=all groupdisplay=cluster;
    discretelegend "b" / title=_label SORTORDER=ASCENDINGFORMATTED ;
       referenceline y=20 / lineattrs=(pattern=4);
       referenceline y=-30 / lineattrs=(pattern=4);
endlayout; 
  endgraph;
end;

ods html close;
ods listing style=styles.lineplot;
proc sgrender data=sashelp.cars template=Waterfall;
/*where STDYPART='B';*/
dynamic _x     = 'origin'
         _y     = 'mpg_city'
   _var   = 'type'
   _label ='Treatment:'
;
run;

Contributor
Posts: 24

Re: barchart not using fillpattern

doh! Im obviously having a brain fart today sorry! also apologies for not taking enough out to enable you to recreate.

The reason Im not seeing patterns is that I'm using E and S for my two styles.

if I change it to the following I get a pattern!

  Style graphdata1 from graphdata1 / MarkerSymbol="circlefilled"  Linestyle=1

              Color=gray Contrastcolor=black  fillpattern = "R1" ;

  Style graphdata2 from graphdata2 / MarkerSymbol="trianglefilled" Linestyle=4

              Color=lightblue   Contrastcolor=blue   fillpattern = "X1" ;

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 539 views
  • 3 likes
  • 2 in conversation