<?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 apply color of format to a different column in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940282#M26738</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thanks, I will mark your answer correct in a day or two, I'm hoping someone else has a better idea. As you might imagine, the real the problem is not about SASHELP.CARS — the real problem has 21 columns going across, and the format has 10–12 different levels. Of course, I can write a macro to implement your suggestion if no one else has a better idea.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 12:59:28 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-08-21T12:59:28Z</dc:date>
    <item>
      <title>PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940144#M26735</link>
      <description>&lt;P&gt;First, I create a table in PROC REPORT where cells are colored according to a predefined format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value msrp 0-20000=yellow 20000&amp;lt;-40000=lightmoderategreen 40000&amp;lt;-99999=lightmoderatered;
run;
ods excel file='temp.xlsx';
proc report data=sashelp.cars(obs=200);
    columns type origin,msrp dummy;
    define type/group;
    define origin/across;
    define msrp/mean;
    define dummy/noprint;
    compute dummy;
        call define("_c2_","style","style={background=msrp.}");
        call define("_c3_","style","style={background=msrp.}");
        call define("_c4_","style","style={background=msrp.}");
    endcompute;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1724181374974.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99477iF210960B5B98099D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1724181374974.png" alt="PaigeMiller_0-1724181374974.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Looks good!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, I want a different table, where instead of MSRP, I want horsepower but I want the colors to remain the same, based upon the format applied to MSRP. It looks like this (fake numbers):&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="PaigeMiller_2-1724181583176.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99479i75841B891C04ED61/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_2-1724181583176.png" alt="PaigeMiller_2-1724181583176.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;See, same colors based upon the format applied to MSRP, but the cells contain the horsepower numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can get the table without the colors, but I don't know what to put in the compute block; as shown the compute block doesn't do what I want. How can I get this second table with the HP numbers but the colors based upon the MSRP colors?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file='temp.xlsx';
proc report data=sashelp.cars(obs=200) out=_ABCD_;
    columns type origin,(msrp horsepower) dummy;
    define type/group;
    define origin/across;
    define msrp/mean noprint;
    define horsepower/'HP' mean;
    define dummy/noprint;
    compute dummy;
        call define("_c5_","style","style={background=msrp.}");
        call define("_c6_","style","style={background=msrp.}");
        call define("_c7_","style","style={background=msrp.}");
    endcompute;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is it not possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 19:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940144#M26735</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-20T19:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940148#M26736</link>
      <description>&lt;P&gt;Do the column number really change if you add a NOPRINT column?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 20:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940148#M26736</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-20T20:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940154#M26737</link>
      <description>&lt;P&gt;I think that first the column numbers need to be addressed. Consider this:&lt;/P&gt;
&lt;PRE&gt;proc report data=sashelp.cars(obs=200) out=_ABCD_;
    columns type origin,(msrp horsepower) dummy;
    define type/group;
    define origin/across;
    define msrp/mean noprint;
    define horsepower/'HP' mean;
    define dummy/noprint;
    compute dummy;
        call define("_c3_","style","style={background=yellow}");
        call define("_c5_","style","style={background=green}");
        call define("_c7_","style","style={background=blue}");
    endcompute;
run;&lt;/PRE&gt;
&lt;P&gt;If the columns used are _c5_&amp;nbsp; _c6_&amp;nbsp; and _c7_ the Europe column is yellow and the USA is blue and the Asia is not colored. So getting the columns numbered correctly appears to be the first challenge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And this duplicates the coloring but not using the format. Perhaps a clue though:&lt;/P&gt;
&lt;PRE&gt;proc report data=sashelp.cars(obs=200) out=_ABCD_;
    columns type origin,(msrp horsepower) dummy;
    define type/group;
    define origin/across;
    define msrp/mean noprint;
    define horsepower/'HP' mean;
    define dummy/computed noprint;
    compute dummy;
        if 0 le _c2_ le 20000 then 
        call define("_c3_","style","style={background=yellow}");
        if 20000 lt _c2_ le 40000 then 
        call define("_c3_","style","style={background=lightmoderategreen}");
        if 40000 lt _c2_ le 999999 then 
        call define("_c3_","style","style={background=lightmoderatered}");

        if 0 le _c4_ le 20000 then 
        call define("_c5_","style","style={background=yellow}");
        if 20000 lt _c4_ le 40000 then 
        call define("_c5_","style","style={background=lightmoderategreen}");
        if 40000 lt _c4_ le 999999 then 
        call define("_c5_","style","style={background=lightmoderatered}");


        if 0 le _c6_ le 20000 then 
        call define("_c7_","style","style={background=yellow}");
        if 20000 lt _c6_ le 40000 then 
        call define("_c7_","style","style={background=lightmoderategreen}");
        if 40000 lt _c6_ le 999999 then 
        call define("_c7_","style","style={background=lightmoderatered}");
    endcomp;
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 21:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940154#M26737</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-20T21:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940282#M26738</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thanks, I will mark your answer correct in a day or two, I'm hoping someone else has a better idea. As you might imagine, the real the problem is not about SASHELP.CARS — the real problem has 21 columns going across, and the format has 10–12 different levels. Of course, I can write a macro to implement your suggestion if no one else has a better idea.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 12:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940282#M26738</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-21T12:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940294#M26739</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Yes, what you want to do IS possible. It is just sort of fiddly. Look at output 10 in this paper &lt;A href="https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf&lt;/A&gt;. Specifically, look at the adjusted code where I create a variable called "SVARn" and then use that variable in the Call Define.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 13:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940294#M26739</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-08-21T13:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940299#M26740</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This looks like a solution I can use. On page 11 it says&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;To see the full code for the COMPUTE block, download the&amp;nbsp;ZIP file of programs that will out on the R&amp;amp;D website on support.sas.com. As a bonus, there is a “macroized” version&amp;nbsp;of this program in the ZIP file, too&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I don't know what the link is to find this code.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 14:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940299#M26740</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-21T14:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT apply color of format to a different column</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940425#M26741</link>
      <description>&lt;P&gt;Hi...sorry, it was moved. YOu'll find it here:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings14/index.html" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings14/index.html&lt;/A&gt;&amp;nbsp;scroll down to the S in the alpha list and there's a link to Download the zip file:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1724288987991.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99547i7693BCF5AE08E789/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1724288987991.png" alt="Cynthia_sas_0-1724288987991.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Have fun with the code!&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 01:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-apply-color-of-format-to-a-different-column/m-p/940425#M26741</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-08-22T01:10:08Z</dc:date>
    </item>
  </channel>
</rss>

