<?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: Proc report : color the group of observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755175#M238272</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The challenge with your approach is using REGION as a GROUP item. I understand why you needed it. But the side effect of GROUP or ORDER usage is that only the first row of the group has a value and repetitive values of other rows in the group are set to missing, which in this case, is the blank. PROC REPORT does not have any visibility of the value for the variable REGION except on the first report row for the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But this is an instance where a helper variable or temporary variable can help you. PROC REPORT automatically retains the value of temporary variables that you use, so in this case, I changed the COMPUTE block to create 3 helper variables based on REGION not being blank (on the first of the GROUP). I also created a user-defined format for the background and foreground colors. I used a subset of just 4 REGION values and one PRODUCT value to make a subset where all the rows would fit in one screen shot so you could see how I was also able to eliminate the IF statement based on using the FORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The other reason this works is that the 3rd argument to the CALL DEFINE (the style values) can be specified with a variable value. I use all of my temporary values in the COMPUTE block for REGION and as you see, the colors for the 3 REGIONS are what I specified and the colors for Pacific were based on the OTHER category in the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the annotated code and output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1626739778478.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61390iED0EB994BB586058/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1626739778478.png" alt="Cynthia_sas_0-1626739778478.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jul 2021 00:10:24 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2021-07-20T00:10:24Z</dc:date>
    <item>
      <title>Proc report : color the group of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755110#M238226</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.shoes;
   column Region n Product  Subsidiary n=n2;

   define Region / group ;
   define Product / group ;
   define Subsidiary  / group ;
   define n / "Nombre de Régions" ;
   define n2 / "Nombre de filiales" ;
   compute Region;
   if Region="Africa" then call define (_ROW_,'style','style=[background=lightblue foreground=red ]');
   endcomp;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm wondering how to color the group of observation for "Africa" please. When I run this code,&amp;nbsp; I have only one row colored :&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="MarieT_0-1626723835198.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61388i6FF3476CFD261CFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1626723835198.png" alt="MarieT_0-1626723835198.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 19:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755110#M238226</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-07-19T19:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : color the group of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755135#M238240</link>
      <description>&lt;P&gt;I recently asked a similar question, which ought to give you enough to solve your problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-how-to-test-group-variable-value-in-COMPUTE-block/m-p/749510#M235535" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-how-to-test-group-variable-value-in-COMPUTE-block/m-p/749510#M235535&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; for the correct answer.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 21:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755135#M238240</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-19T21:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : color the group of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755175#M238272</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The challenge with your approach is using REGION as a GROUP item. I understand why you needed it. But the side effect of GROUP or ORDER usage is that only the first row of the group has a value and repetitive values of other rows in the group are set to missing, which in this case, is the blank. PROC REPORT does not have any visibility of the value for the variable REGION except on the first report row for the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But this is an instance where a helper variable or temporary variable can help you. PROC REPORT automatically retains the value of temporary variables that you use, so in this case, I changed the COMPUTE block to create 3 helper variables based on REGION not being blank (on the first of the GROUP). I also created a user-defined format for the background and foreground colors. I used a subset of just 4 REGION values and one PRODUCT value to make a subset where all the rows would fit in one screen shot so you could see how I was also able to eliminate the IF statement based on using the FORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The other reason this works is that the 3rd argument to the CALL DEFINE (the style values) can be specified with a variable value. I use all of my temporary values in the COMPUTE block for REGION and as you see, the colors for the 3 REGIONS are what I specified and the colors for Pacific were based on the OTHER category in the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the annotated code and output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1626739778478.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61390iED0EB994BB586058/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1626739778478.png" alt="Cynthia_sas_0-1626739778478.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 00:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755175#M238272</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-07-20T00:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report : color the group of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755242#M238316</link>
      <description>Thank you very much Cynthia!</description>
      <pubDate>Tue, 20 Jul 2021 06:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-report-color-the-group-of-observations/m-p/755242#M238316</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-07-20T06:55:16Z</dc:date>
    </item>
  </channel>
</rss>

