<?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 Using attribute map in proc template in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795648#M22577</link>
    <description>&lt;P&gt;I am doing a multicell plot in GTL with some barcharts and what to control the colors with an attributemap.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The grouping within each of the cell plots are different .&amp;nbsp;To illustrate the "problem" I have played with sashelp.cars where the two plots use&amp;nbsp;car type for group, the other drive train.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first cell we have a barchart of engine size by car type.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second cell we have a barchart of engine size by drive train.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The plot itself is okay as such but I want to control the colors with an attributemap.&lt;/P&gt;&lt;P&gt;I also want to show a legend group item if data is available for that group. Have tried several work around by can not get it to work......&amp;nbsp;&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="example_cars.jpg" style="width: 628px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68388i915BF0E8A6755051/image-size/large?v=v2&amp;amp;px=999" role="button" title="example_cars.jpg" alt="example_cars.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data attrmap;
retain ID "cars"
       linecolor "black";
input  
      VALUE $   1-9     
      FILLCOLOR $ 10-19  
      FILLPATTERN $ 20-29
      ;
*--------1---------2---------3---------4---------5---------6---------7---------8---------9;
datalines;
Hybrid   black     solid
SUV      yellow    solid
Sedan    blue      solid
Sports   vivid     solid
Truck    hue       solid
Wagon    orange    solid
All      red       l1
Front    green     l2
Rear     yellow    l3
;
run;


proc template;
   define statgraph multicell;
      begingraph;
        layout lattice   / rowgutter=10px 
                           columngutter=10px;
          layout overlay;
                entry "Car type" / valign=top;
               barchart  x=origin y=engine/ group=type name="legend_1" ;
               discretelegend "legend_1" /displayclipped=true 
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;

         layout overlay;
               entry "Car drivetrain" / valign=top;
               barchart  x=origin y=engine/ group=drivetrain name="legend_2" ;
               discretelegend "legend_2" /displayclipped=true 
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;
         
      endlayout;
   endgraph;
end;
run;


proc summary data=sashelp.cars;
   class origin type drivetrain;
   var enginesize;
   output mean=engine out=data4plot;
run; 

proc sgrender data=data4plot template=multicell dattrmap=work.attrmap;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Feb 2022 13:07:06 GMT</pubDate>
    <dc:creator>Claus_Stenberg</dc:creator>
    <dc:date>2022-02-11T13:07:06Z</dc:date>
    <item>
      <title>Using attribute map in proc template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795648#M22577</link>
      <description>&lt;P&gt;I am doing a multicell plot in GTL with some barcharts and what to control the colors with an attributemap.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The grouping within each of the cell plots are different .&amp;nbsp;To illustrate the "problem" I have played with sashelp.cars where the two plots use&amp;nbsp;car type for group, the other drive train.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first cell we have a barchart of engine size by car type.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the second cell we have a barchart of engine size by drive train.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The plot itself is okay as such but I want to control the colors with an attributemap.&lt;/P&gt;&lt;P&gt;I also want to show a legend group item if data is available for that group. Have tried several work around by can not get it to work......&amp;nbsp;&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="example_cars.jpg" style="width: 628px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68388i915BF0E8A6755051/image-size/large?v=v2&amp;amp;px=999" role="button" title="example_cars.jpg" alt="example_cars.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data attrmap;
retain ID "cars"
       linecolor "black";
input  
      VALUE $   1-9     
      FILLCOLOR $ 10-19  
      FILLPATTERN $ 20-29
      ;
*--------1---------2---------3---------4---------5---------6---------7---------8---------9;
datalines;
Hybrid   black     solid
SUV      yellow    solid
Sedan    blue      solid
Sports   vivid     solid
Truck    hue       solid
Wagon    orange    solid
All      red       l1
Front    green     l2
Rear     yellow    l3
;
run;


proc template;
   define statgraph multicell;
      begingraph;
        layout lattice   / rowgutter=10px 
                           columngutter=10px;
          layout overlay;
                entry "Car type" / valign=top;
               barchart  x=origin y=engine/ group=type name="legend_1" ;
               discretelegend "legend_1" /displayclipped=true 
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;

         layout overlay;
               entry "Car drivetrain" / valign=top;
               barchart  x=origin y=engine/ group=drivetrain name="legend_2" ;
               discretelegend "legend_2" /displayclipped=true 
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;
         
      endlayout;
   endgraph;
end;
run;


proc summary data=sashelp.cars;
   class origin type drivetrain;
   var enginesize;
   output mean=engine out=data4plot;
run; 

proc sgrender data=data4plot template=multicell dattrmap=work.attrmap;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 13:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795648#M22577</guid>
      <dc:creator>Claus_Stenberg</dc:creator>
      <dc:date>2022-02-11T13:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using attribute map in proc template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795664#M22578</link>
      <description>&lt;P&gt;There are two things you need to do here:&lt;/P&gt;
&lt;P&gt;1. Split the attrmap into two separate attrmap within the same data set so that you can address them with difference group variables. To do this, input the ID via the datalines instead of retaining one ID.&lt;/P&gt;
&lt;P&gt;2. You need to use a DATTRVAR statement in SGRENDER to bind the correct map to each group variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is your modified example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data attrmap;
retain linecolor "black";
input
      VALUE $   1-9
      FILLCOLOR $ 10-19
      FILLPATTERN $ 20-29
      ID          $ 30-34
      ;
*--------1---------2---------3---------4---------5---------6---------7---------8---------9;
datalines;
Hybrid   black     solid     type
SUV      yellow    solid     type
Sedan    blue      solid     type
Sports   vivid     solid     type
Truck    hue       solid     type
Wagon    orange    solid     type
All      red       l1        drive
Front    green     l2        drive
Rear     yellow    l3        drive
;
run;

proc template;
   define statgraph multicell;
      begingraph;
        layout lattice   / rowgutter=10px
                           columngutter=10px;
          layout overlay;
                entry "Car type" / valign=top;
               barchart  x=origin y=engine/ group=type name="legend_1" ;
               discretelegend "legend_1" /displayclipped=true
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;

         layout overlay;
               entry "Car drivetrain" / valign=top;
               barchart  x=origin y=engine/ group=drivetrain name="legend_2" ;
               discretelegend "legend_2" /displayclipped=true
                                           autoitemsize=true
                                           LOCATION=outside;
         endlayout;

      endlayout;
   endgraph;
end;
run;

proc summary data=sashelp.cars;
   class origin type drivetrain;
   var enginesize;
   output mean=engine out=data4plot;
run;

proc sgrender data=data4plot template=multicell dattrmap=work.attrmap;
dattrvar type="type" drivetrain="drive";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Feb 2022 14:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795664#M22578</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2022-02-11T14:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using attribute map in proc template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795676#M22580</link>
      <description>&lt;P&gt;Thanks a million -&amp;nbsp; works like a charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Claus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS just noticed that a forgot a "nway" in my proc summary but that is a small detail that has nothing to do with the solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 14:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Using-attribute-map-in-proc-template/m-p/795676#M22580</guid>
      <dc:creator>Claus_Stenberg</dc:creator>
      <dc:date>2022-02-11T14:41:31Z</dc:date>
    </item>
  </channel>
</rss>

