<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Attribute map not mapping to correct groups in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687394#M20527</link>
    <description>I have updated the original to include that, so that Polling_Organisation is read properly.</description>
    <pubDate>Tue, 29 Sep 2020 02:10:17 GMT</pubDate>
    <dc:creator>JacquesR</dc:creator>
    <dc:date>2020-09-29T02:10:17Z</dc:date>
    <item>
      <title>Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687382#M20523</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;Here is some data from a Wikipedia page:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data polls;
input Date $15. @16 Polling_Organisation $21. @38 For F_LCL F_UCL Against A_LCL A_UCL Predicted_Outcome $ 9.;
datalines;
2–17 Jul 2018  Curia Market Research 49.0 47.4 50.6 -47.0 -45.5 -48.5 Undecided 
15–19 Oct 2018 1 News Colmar Brunton 46.0 44.6 47.4 -41.0 -39.7 -42.3 For 
10–26 Oct 2018 Horizon Research      60.0 58.1 61.9 -24.0 -23.3 -24.7 For 
3–17 Mar 2019  Research New Zealand  29.0 28.2 29.8 -49.0 -47.6 -50.4 Against 
9 May 2019     Horizon Research      52.0 50.5 53.5 -37.0 -35.9 -38.1 For 
4–8 Jun 2019   1 News Colmar Brunton 39.0 37.8 40.2 -52.0 -50.4 -53.6 Against 
3–4 Aug 2019   Horizon Research      39.0 37.8 40.2 -47.0 -45.5 -48.5 Against 
11–17 Nov 2019 Horizon Research      48.0 46.6 49.4 -38.0 -36.9 -39.1 For 
23–27 Nov 2019 1 News Colmar Brunton 43.0 41.7 44.3 -49.0 -47.5 -50.5 Against 
8–12 Feb 2020  1 News Colmar Brunton 39.0 37.8 40.2 -51.0 -49.4 -52.6 Against 
21–26 Feb 2020 Horizon Research      54.0 52.8 55.2 -45.0 -44.0 -46.0 For 
6–9 Mar 2020   Research New Zealand  43.0 41.7 44.3 -33.0 -32.0 -34.0 For 
10–14 Jun 2020 Horizon Research      56.0 54.6 57.4 -43.0 -41.9 -44.1 For 
20–24 Jun 2020 1 News Colmar Brunton 40.0 38.8 41.2 -49.0 -47.5 -50.5 Against 
9–13 Jul 2020  Research New Zealand  43.0 41.7 44.3 -39.0 -37.8 -40.2 For 
20–23 Aug 2020 Research New Zealand  39.0 37.8 40.2 -46.0 -44.6 -47.4 Against 
20–25 Aug 2020 Horizon Research      50.0 . . -50.0 . . Undecided 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the attribute map:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _AttrMap;
    LENGTH value $ 9 FillPattern $ 2 lineColor $ 5;
    INPUT ID $ Value $ FillPattern $ lineColor $;
    DATALINES;
    hbar Against   L1 black
    hbar For       R1 black
    hbar Undecided X1 black
    ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And finally, this is how I plot it (please excuse the caps):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ODS GRAPHICS /WIDTH=1000 HEIGHT=600 MAXLEGENDAREA=100
              IMAGENAME="Polls"
              attrpriority=none;
PROC SGPLOT
    NOBORDER
    NOCYCLEATTRS
    DATA=polls
    DATTRMAP=_AttrMap
    ;
    /* Put Polling_Organisation in the Yaxistable */
    YAXISTABLE Polling_Organisation
               /LOCATION=INSIDE
                POSITION=LEFT
    ;
    XAXIS LABEL="Percentage For/Against (Undecided not shown)" VALUES=(-100 TO 100 BY 10);
    HBARPARM 
        CATEGORY=Date
        RESPONSE=For
       /NOFILL FILLPATTERN
        GROUP=Predicted_Outcome
        GROUPDISPLAY=CLUSTER ATTRID=hbar
        GROUPORDER=DATA
        LIMITLOWER=F_LCL 
        LIMITUPPER=F_UCL
        LIMITATTRS=(COLOR=Black)
        NAME="Leg"
    ; 
    HBARPARM 
        CATEGORY=Date
        RESPONSE=Against
       /NOFILL FILLPATTERN
        GROUP=Predicted_Outcome
        GROUPDISPLAY=CLUSTER ATTRID=hbar
        GROUPORDER=DATA
        LIMITLOWER=A_LCL 
        LIMITUPPER=A_UCL
        LIMITATTRS=(COLOR=Black)
    ; 
    KEYLEGEND "Leg" /TITLE="Poll outcome";
    REFLINE -50 50 /AXIS=X LINEATTRS=(PATTERN=ShortDash);
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Everything works, except that the legend is not mapping the correct pattern to the correct group value (see below).&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Polls.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49913iF1007B42B42B8759/image-size/large?v=v2&amp;amp;px=999" role="button" title="Polls.png" alt="Polls.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 21:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687382#M20523</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-10-05T21:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687390#M20524</link>
      <description>&lt;P&gt;Have you printed your data sets to ensure that you have the values that you think you have?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 02:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687390#M20524</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2020-09-29T02:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687391#M20525</link>
      <description>I coped the datalines from a proc print.</description>
      <pubDate>Tue, 29 Sep 2020 02:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687391#M20525</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-09-29T02:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687393#M20526</link>
      <description>Apologies. I started writing this yesterday, and then loaded the post from the website's autosave. I forgot to change this:&lt;BR /&gt;Polling_Organisation $21.&lt;BR /&gt;However, that does not change the data needed for the plot (Polling_Organisation appears in the yaxis table, but is not the grouping variable).</description>
      <pubDate>Tue, 29 Sep 2020 02:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687393#M20526</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-09-29T02:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687394#M20527</link>
      <description>I have updated the original to include that, so that Polling_Organisation is read properly.</description>
      <pubDate>Tue, 29 Sep 2020 02:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/687394#M20527</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-09-29T02:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/691061#M20576</link>
      <description>&lt;P&gt;I do not believe controlling the sgplot hbarparm fillpattern with dattrmap is supported yet. (If you have seen documentation indicating that it is supported, let me know and I'll check more into it.) The patterns you were seeing were just the default ones (which happened to almost correspond to the ones you were specifying, but in the wrong order).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since that technique is not supported, you'll have to use a more indirect/hard-coded/order-dependent technique, such as using a styleattrs statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;styleattrs datafillpatterns=(X1 R1 L1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a modified version of your code, using styleattrs to control the patterns. I've also changed your dattrmap colors to make it easier to see if they're affecting the graph:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data polls;&lt;BR /&gt;length Date $16 Polling_Organisation $50 Predicted_Outcome $9;&lt;BR /&gt;infile datalines dlm=':';&lt;BR /&gt;input Date Polling_Organisation For F_LCL F_UCL Against A_LCL A_UCL Predicted_Outcome;&lt;BR /&gt;datalines;&lt;BR /&gt;2-17 Jul 2018 :Curia Market Research :49.0:47.4:50.6:-47.0:-45.5:-48.5:Undecided&lt;BR /&gt;15-19 Oct 2018 :1 News Colmar Brunton :46.0:44.6:47.4:-41.0:-39.7:-42.3:For&lt;BR /&gt;10-26 Oct 2018 :Horizon Research :60.0:58.1:61.9:-24.0:-23.3:-24.7:For&lt;BR /&gt;3-17 Mar 2019 :Research New Zealand :29.0:28.2:29.8:-49.0:-47.6:-50.4:Against&lt;BR /&gt;9 May 2019 :Horizon Research :52.0:50.5:53.5:-37.0:-35.9:-38.1:For&lt;BR /&gt;4-8 Jun 2019 :1 News Colmar Brunton :39.0:37.8:40.2:-52.0:-50.4:-53.6:Against&lt;BR /&gt;3-4 Aug 2019 :Horizon Research :39.0:37.8:40.2:-47.0:-45.5:-48.5:Against&lt;BR /&gt;11-17 Nov 2019 :Horizon Research :48.0:46.6:49.4:-38.0:-36.9:-39.1:For&lt;BR /&gt;23-27 Nov 2019 :1 News Colmar Brunton :43.0:41.7:44.3:-49.0:-47.5:-50.5:Against&lt;BR /&gt;8-12 Feb 2020 :1 News Colmar Brunton :39.0:37.8:40.2:-51.0:-49.4:-52.6:Against&lt;BR /&gt;21-26 Feb 2020 :Horizon Research :54.0:52.8:55.2:-45.0:-44.0:-46.0:For&lt;BR /&gt;6-9 Mar 2020 :Research New Zealand :43.0:41.7:44.3:-33.0:-32.0:-34.0:For&lt;BR /&gt;10-14 Jun 2020 :Horizon Research :56.0:54.6:57.4:-43.0:-41.9:-44.1:For&lt;BR /&gt;20-24 Jun 2020 :1 News Colmar Brunton :40.0:38.8:41.2:-49.0:-47.5:-50.5:Against&lt;BR /&gt;9-13 Jul 2020 :Research New Zealand :43.0:41.7:44.3:-39.0:-37.8:-40.2:For&lt;BR /&gt;20-23 Aug 2020 :Research New Zealand :39.0:37.8:40.2:-46.0:-44.6:-47.4:Against&lt;BR /&gt;20-25 Aug 2020 :Horizon Research :50.0:.:.:-50.0:.:.:Undecided&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA _AttrMap;&lt;BR /&gt;LENGTH value $ 9 FillPattern $ 2 lineColor $ 5;&lt;BR /&gt;INPUT ID $ Value $ lineColor $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;hbar Against red&lt;BR /&gt;hbar For green&lt;BR /&gt;hbar Undecided gray&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ODS GRAPHICS /WIDTH=1000 HEIGHT=600 MAXLEGENDAREA=100 imagemap&lt;BR /&gt;IMAGENAME="Polls"&lt;BR /&gt;attrpriority=none;&lt;/P&gt;
&lt;P&gt;title "Sgplot";&lt;BR /&gt;PROC SGPLOT&lt;BR /&gt;NOBORDER&lt;BR /&gt;NOCYCLEATTRS&lt;BR /&gt;DATA=polls&lt;BR /&gt;DATTRMAP=_AttrMap&lt;BR /&gt;;&lt;BR /&gt;/* Put Polling_Organisation in the Yaxistable */&lt;BR /&gt;YAXISTABLE Polling_Organisation&lt;BR /&gt;/LOCATION=INSIDE&lt;BR /&gt;POSITION=LEFT&lt;BR /&gt;;&lt;BR /&gt;XAXIS LABEL="Percentage For/Against (Undecided not shown)" VALUES=(-100 TO 100 BY 10);&lt;BR /&gt;styleattrs datafillpatterns=(X1 R1 L1);&lt;BR /&gt;HBARPARM&lt;BR /&gt;CATEGORY=Date&lt;BR /&gt;RESPONSE=For&lt;BR /&gt;/ NOFILL FILLPATTERN&lt;BR /&gt;GROUP=Predicted_Outcome&lt;BR /&gt;GROUPDISPLAY=CLUSTER ATTRID=hbar&lt;BR /&gt;GROUPORDER=DATA&lt;BR /&gt;LIMITLOWER=F_LCL&lt;BR /&gt;LIMITUPPER=F_UCL&lt;BR /&gt;LIMITATTRS=(COLOR=Black)&lt;BR /&gt;NAME="Leg"&lt;BR /&gt;;&lt;BR /&gt;HBARPARM&lt;BR /&gt;CATEGORY=Date&lt;BR /&gt;RESPONSE=Against&lt;BR /&gt;/NOFILL FILLPATTERN&lt;BR /&gt;GROUP=Predicted_Outcome&lt;BR /&gt;GROUPDISPLAY=CLUSTER ATTRID=hbar&lt;BR /&gt;GROUPORDER=DATA&lt;BR /&gt;LIMITLOWER=A_LCL&lt;BR /&gt;LIMITUPPER=A_UCL&lt;BR /&gt;LIMITATTRS=(COLOR=Black)&lt;BR /&gt;;&lt;BR /&gt;KEYLEGEND "Leg" /TITLE="Poll outcome";&lt;BR /&gt;REFLINE -50 50 /AXIS=X LINEATTRS=(PATTERN=ShortDash);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="polling.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50575iA6170139C24B6ED9/image-size/large?v=v2&amp;amp;px=999" role="button" title="polling.png" alt="polling.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 19:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/691061#M20576</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2020-10-12T19:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute map not mapping to correct groups</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/691107#M20577</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13585"&gt;@GraphGuy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When no one answered, I tried reaching out to SAS tech support, and they did confirm what you stated above: This is not supported as yet, which is a pity.&lt;/P&gt;&lt;P&gt;They pointed me to a proc template example(&lt;A href="https://support.sas.com/kb/45/663.html" target="_self"&gt;https://support.sas.com/kb/45/663.html&lt;/A&gt;), which I was able to use to get the desired outcome:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
    define style mypatterns;
    parent=styles.listing;
/* The GraphBar element must be included with the
FILLPATTERN option in order to use fill patterns. */
  style GraphBar from GraphComponent / 
  displayopts = "fillpattern"; 

/* Fill patterns are defined using the FILLPATTERN 
style element attribute. 
COLOR is used for the bar fill colors
CONTRASTCOLOR is used for the line colors */

style GraphData1 from GraphData1 / 
    FillPattern = "X1"
    ContrastColor=black
; 
style GraphData2 from GraphData2 /
    FillPattern = "R1"
    ContrastColor=black
; 
style GraphData3 from GraphData3 / 
    FillPattern = "L1"
    ContrastColor=black
; 
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 00:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Attribute-map-not-mapping-to-correct-groups/m-p/691107#M20577</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-10-13T00:32:39Z</dc:date>
    </item>
  </channel>
</rss>

