<?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: Bolding One Cell Value Based on Comparison with Another in PROC REPORT in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677828#M24352</link>
    <description>&lt;P&gt;I have crafted a test set to explain what I mean (the NOPRINT columns are something else I'm working with that's already settled).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input cat $ a b;
datalines;
A 4 5 
B 2 7
C 8 4
D 1 9
;
run;

proc report data=test nowd;
	column cat a b;
	define cat / '' group order = data;
	define a / 'a' analysis pctsum format=percent8.1;
	define b / 'b' analysis pctsum format=percent8.1;

	compute b;
		if b &amp;gt; a then call define(_col_,'style','style={font_weight=bold}');
	endcomp;

	rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The COMPUTE block is where I need help. I want it to compare the PCTSUM in each row for a and b. If the PCTSUM of b is larger, I want to bold b in that row; if the PCTSUM of a is larger, I want to bold a in that row. (It's highly unlikely that they will be equal in my application, but I guess we could make the first condition greater than or equal to.) Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Aug 2020 15:20:16 GMT</pubDate>
    <dc:creator>tburus</dc:creator>
    <dc:date>2020-08-19T15:20:16Z</dc:date>
    <item>
      <title>Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677701#M24349</link>
      <description>&lt;P&gt;I have a PROC REPORT table in which I want to bold cell based on comparison with other cells. Here is the code and current output.&lt;/P&gt;
&lt;P&gt;Code:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=gender_t2c nowd split="*"
		style(report)=[frame=hsides rules=none]
		style(header)=[background=white color=&amp;amp;rgreen. borderbottomcolor=black]
		style(lines)=[background=white];
	column injsite boys_soccer girls_soccer estimate lowercl uppercl ci;
	define injsite / 'Body Site' group order = data;
	define boys_soccer / "Boys' Soccer" analysis pctsum format=pct. style(column)=[cellwidth=1.5in just=c];
	define girls_soccer / "Girls' Soccer" analysis pctsum format=pct. style(column)=[cellwidth=1.5in just=c];
	define estimate / '' display noprint;
	define lowercl / '' display noprint;
	define uppercl / '' display noprint;
	define ci / "IPR (95% CI)" display style(column)=[cellwidth=1.5in just=c];

	rbreak after / summarize style(summary)={font_weight=bold};
	compute after;
		injsite = 'Total';
	endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot.png" style="width: 612px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48406iCC0FFD24C843F198/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot.png" alt="plot.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;There are two comparisons/boldings that I want to perform:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Bold the cell value between Boys' Soccer and Girls' Soccer that is the largest&lt;/LI&gt;
&lt;LI&gt;Bold any IPRs where 1 is not in the interval given&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I am exploring how to do this with COMPUTE and CALL DEFINE commands, but cannot quite make it work.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 05:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677701#M24349</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-19T05:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677757#M24350</link>
      <description>&lt;P&gt;Provide example data in the form of a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 11:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677757#M24350</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-19T11:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677809#M24351</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;What code have you tried? You said you can't make it work. Nobody else can make it work without making up some fake data including your NOPRINT variables which do not seem to be used. PROC REPORT has 2 rules that you need to consider before you try to apply changes with CALL DEFINE:&lt;BR /&gt;1) you have to refer to analysis items by their "internal name" -- which is &lt;EM&gt;&lt;STRONG&gt;variable.statistic&lt;/STRONG&gt; &lt;/EM&gt;&lt;BR /&gt;2) PROC REPORT has a "left to right" rule -- each item is placed on the report row, one item at a time. So for example, with this column statement:&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;column cat a b tot;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;at the point in time that PROC REPORT is writing &lt;STRONG&gt;CAT&lt;/STRONG&gt; on the report row, it has no visibility of the values of &lt;STRONG&gt;A, B&lt;/STRONG&gt; or &lt;STRONG&gt;TOT&lt;/STRONG&gt;. When Proc Report places &lt;STRONG&gt;A&lt;/STRONG&gt; on the report row, then it has visibility of only the value for &lt;STRONG&gt;A&lt;/STRONG&gt; and &lt;STRONG&gt;CAT&lt;/STRONG&gt; (there is no visibility for &lt;STRONG&gt;B&lt;/STRONG&gt; or &lt;STRONG&gt;TOT&lt;/STRONG&gt; yet). So working from left to right you can't do a comparison between &lt;STRONG&gt;A&lt;/STRONG&gt; and &lt;STRONG&gt;B&lt;/STRONG&gt; (for example) until both &lt;STRONG&gt;A&lt;/STRONG&gt; and &lt;STRONG&gt;B&lt;/STRONG&gt; have been placed on the report row. This means a comparison will fail if placed in a COMPUTE block for &lt;STRONG&gt;A&lt;/STRONG&gt;, but will work when placed in the COMPUTE block for &lt;STRONG&gt;B&lt;/STRONG&gt; or &lt;STRONG&gt;TOT&lt;/STRONG&gt; (which are to the right of &lt;STRONG&gt;A&lt;/STRONG&gt; on the report row).&lt;BR /&gt;&lt;BR /&gt;Consider this example with fake data, since you did not show all your code or provide any data:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1597847605203.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48415iCAEB3626D9E7794C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1597847605203.png" alt="Cynthia_sas_0-1597847605203.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Note the use of &lt;STRONG&gt;A.SUM&lt;/STRONG&gt; and &lt;STRONG&gt;B.SUM&lt;/STRONG&gt; in the code because both &lt;STRONG&gt;A&lt;/STRONG&gt; and &lt;STRONG&gt;B&lt;/STRONG&gt; are analysis items and the statistic requested is &lt;STRONG&gt;SUM&lt;/STRONG&gt;. If I had requested the &lt;STRONG&gt;MEAN&lt;/STRONG&gt;, then the reference would have been &lt;STRONG&gt;A.MEAN&lt;/STRONG&gt; and &lt;STRONG&gt;B.MEAN&lt;/STRONG&gt;, etc.&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 14:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677809#M24351</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-08-19T14:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677828#M24352</link>
      <description>&lt;P&gt;I have crafted a test set to explain what I mean (the NOPRINT columns are something else I'm working with that's already settled).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input cat $ a b;
datalines;
A 4 5 
B 2 7
C 8 4
D 1 9
;
run;

proc report data=test nowd;
	column cat a b;
	define cat / '' group order = data;
	define a / 'a' analysis pctsum format=percent8.1;
	define b / 'b' analysis pctsum format=percent8.1;

	compute b;
		if b &amp;gt; a then call define(_col_,'style','style={font_weight=bold}');
	endcomp;

	rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The COMPUTE block is where I need help. I want it to compare the PCTSUM in each row for a and b. If the PCTSUM of b is larger, I want to bold b in that row; if the PCTSUM of a is larger, I want to bold a in that row. (It's highly unlikely that they will be equal in my application, but I guess we could make the first condition greater than or equal to.) Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 15:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677828#M24352</guid>
      <dc:creator>tburus</dc:creator>
      <dc:date>2020-08-19T15:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677875#M24353</link>
      <description>&lt;P&gt;Since font weight isn't always obvious enough I colored the cell yellow or pink:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data=test nowd;
	column cat a b;
	define cat / '' group order = data;
	define a / 'a' analysis pctsum format=percent8.1;
	define b / 'b' analysis pctsum format=percent8.1;

	compute b;
	     if b.pctsum &amp;gt; a.pctsum then call define(_col_,'style','style={font_weight=bold background=yellow}');
             if a.pctsum &amp;gt; b.pctsum then call define(2,'style','style={font_weight=bold background=pink}');
	endcomp;

	rbreak after / summarize;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; stated that you need to reference the calculated statistic for the comparison. Note that the 2 in the second statement is the column number of the A statistic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 17:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677875#M24353</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-19T17:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Bolding One Cell Value Based on Comparison with Another in PROC REPORT</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677885#M24354</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; As I explained in my posting, you MUST use the &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;variable&lt;/FONT&gt;.&lt;FONT color="#0000FF"&gt;statistic&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt; reference in a COMPUTE block for your reference to any variables. Here are some examples:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;A&lt;/FONT&gt;.&lt;FONT color="#0000FF"&gt;SUM&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;B&lt;/FONT&gt;.&lt;FONT color="#0000FF"&gt;SUM&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;A&lt;/FONT&gt;.&lt;FONT color="#0000FF"&gt;MEAN&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Otherwise, PROC REPORT will generate an error. So if &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/FONT&gt; is an analysis variable and if the statistic for &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;A&lt;/FONT&gt; &lt;/STRONG&gt;is &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;PCTSUM&lt;/FONT&gt;&lt;/STRONG&gt; -- then the compound name for referencing purpose would need to be &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;A&lt;/FONT&gt;.&lt;FONT color="#0000FF"&gt;PCTSUM&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt; -- that is the rule I mentioned in my post. And there are other ways you could reference the column, such as indirect reference or macro variable or some other resolved method. But I prefer to show the compound name because that will always work, even if another item gets inserted into the row and the number could change. For example, if the column statement was&amp;nbsp;&lt;/P&gt;
&lt;P&gt;column CAT GRP A B, then the number for A would change. but the reference of A.PCTSUM would NOT change, even if the position changed. (As long as the statistic was the same.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 18:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Bolding-One-Cell-Value-Based-on-Comparison-with-Another-in-PROC/m-p/677885#M24354</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-08-19T18:40:01Z</dc:date>
    </item>
  </channel>
</rss>

