You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在SAS 9.4的SGPanel同色系组内用填充图案区分VBAR

How to Add Fill Patterns to Same-Color Groups in SAS SGPanel VBAR Charts

Got it, let's tackle this! You want to differentiate groups that share the same color in your SGPanel bar chart using fill patterns—totally doable in SAS 9.4. Here's exactly how to adjust your code:

First, we'll add fill pattern definitions to your STYLEATTRS statement, matching the order of your existing color list. Then we'll tell the VBAR statement to apply these patterns by group.

Modified Code

proc sgpanel data=transp_5;
  panelby position / layout=columnlattice onepanel colheaderpos=bottom rows=2 novarname noborder;
  /* Add DATAPATTERNS to pair with your repeated color scheme */
  styleattrs 
    datacolours=(CXbe0a6e CXbe0a6e CXe17d00 CXe17d00 CXbcc121 CXbcc121 CX3caf7f CX3caf7f CX0077ad CX0077ad)
    datapatterns(SOLID X SOLID DOT SOLID DIAMOND SOLID CROSS SOLID STAR) /* Alternate patterns for same-color groups */
    DATACONTRASTCOLORS=(nocolour);
  format position order.;
  format crop_type concatf.;
  /* Enable fill patterns for the group with FILLPATTERN=GROUP */
  vbar crop_type / group=crop_type response=col1 stat=sum fillpattern=group;
run;

Key Details:

  • DATAPATTERNS in STYLEATTRS: This list maps directly to your datacolours list. For each pair of same-color groups, we use a different pattern (e.g., SOLID and X for the first two groups, SOLID and DOT for the next pair). SAS 9.4 supports patterns like SOLID, X, DOT, DIAMOND, CROSS, STAR, HORIZONTAL, VERTICAL, etc.—feel free to swap these out for ones that work best for your chart.
  • FILLPATTERN=GROUP in VBAR: This option tells SAS to apply the pattern defined in DATAPATTERNS to each group, ensuring same-color bars get distinct fill patterns.
  • Format Alignment: Make sure the order of your concatf. format for crop_type matches the order of datacolours and datapatterns—this ensures the right pattern/color is applied to each group.

内容的提问来源于stack exchange,提问作者Sandra L.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:30:04