<?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 rows If there is change in value between specific columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875713#M346015</link>
    <description>Hi:&lt;BR /&gt;  What code have you tried? This is going to need a COMPUTE block and you're either going to need to pre-process your data to create a flag variable that can be used to determine whether the row should be highlighted. If you don't pre-process the data ahead of time, then you'll need to do your comparison of all the variables in the report row on  the last variable you display before you'd have enough information to highlight the row. Remember the left-to-right rule of PROC REPORT. Until PROC REPORT has placed ALL the MONx variables on the report row, you can't test them ALL against each other. &lt;BR /&gt;Cynthia</description>
    <pubDate>Mon, 15 May 2023 01:07:32 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2023-05-15T01:07:32Z</dc:date>
    <item>
      <title>Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875703#M346012</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have data set in Long structure.&lt;/P&gt;
&lt;P&gt;This data set included information two groups of columns:&lt;/P&gt;
&lt;P&gt;1-Columns with general information about customer (These rows are with value&amp;nbsp;Var_groups=1)&lt;/P&gt;
&lt;P&gt;2-&amp;nbsp;Columns with&amp;nbsp; information of categorical explanatory variables&amp;nbsp; (These rows are with value&amp;nbsp;Var_groups=2)&lt;/P&gt;
&lt;P&gt;My task:&lt;/P&gt;
&lt;P&gt;Create printed report with same structure (Long)&lt;/P&gt;
&lt;P&gt;that will color rows that their values in columns mon1,mon2,mon3,mon4,mon5,mon6&amp;nbsp; are not equal each other&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(IF there is one column that differ from other than need to color all row in yellow)&lt;/P&gt;
&lt;P&gt;I want to apply this rule only on rows with value&amp;nbsp;Var_groups=2&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data summary_Report_Long_Strcuture;
infile datalines delimiter=',';
Input  Var_name $  Var_groups $ Mon1 $ Mon2  $ Mon3 $ Mon4  $ Mon5 $ Mon6 $;
cards;
month,1,2210,2211,2212,2301,2302,2303
customer,1,777,777,777,777,777,777
branch,1,23,23,23,23,23,23
X1,2,a,a,a,a,a,a 
W1,2,1,1,1,2,1,1 
Z1,2,1,1,1,1,1,1 
X1,2,1,2,1,1,1,1 
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_1-1684101313739.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83966i1447C32015D07E0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_1-1684101313739.png" alt="Ronein_1-1684101313739.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>Sun, 14 May 2023 21:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875703#M346012</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-14T21:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875713#M346015</link>
      <description>Hi:&lt;BR /&gt;  What code have you tried? This is going to need a COMPUTE block and you're either going to need to pre-process your data to create a flag variable that can be used to determine whether the row should be highlighted. If you don't pre-process the data ahead of time, then you'll need to do your comparison of all the variables in the report row on  the last variable you display before you'd have enough information to highlight the row. Remember the left-to-right rule of PROC REPORT. Until PROC REPORT has placed ALL the MONx variables on the report row, you can't test them ALL against each other. &lt;BR /&gt;Cynthia</description>
      <pubDate>Mon, 15 May 2023 01:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875713#M346015</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2023-05-15T01:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875725#M346017</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;I created this code but I cannot see any line with color in the output report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data summary_Report_Long_Strcuture;
infile datalines delimiter=',';
Input  Var_name $  Var_groups $ Mon1 $ Mon2  $ Mon3 $ Mon4  $ Mon5 $ Mon6 $;
cards;
month,1,2210,2211,2212,2301,2302,2303
customer,1,777,777,777,777,777,777
branch,1,23,23,23,23,23,23
X1,2,a,a,a,a,a,a 
W1,2,1,1,1,2,1,1 
Z1,2,1,1,1,1,1,1 
X1,2,1,2,1,1,1,1 
;
Run;

 data want;
 set summary_Report_Long_Strcuture;
 IF Var_groups=2 and ((Mon2 ne Mon1) OR (Mon3 ne Mon2)OR (Mon4 ne Mon3)OR (Mon5 ne Mon4)OR (Mon6 ne Mon5))  then Ind_Change=1;else Ind_Change=0;
 Run;


proc report data=want nowd ;
column Var_name Var_groups Mon1 Mon2 Mon3 Mon4 Mon5 Mon6 Ind_Change;
define Var_name   /display;
define Var_groups   /display;
define Mon1   /display;
define Mon2   /display;
define Mon3   /display;
define Mon4   /display;
define Mon5   /display;
define Mon6   /display;
compute Ind_Change;
if Ind_Change=1 then
call define(_row_, "style", "style=[backgroundcolor=yellow]");
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 05:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875725#M346017</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-15T05:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875761#M346036</link>
      <description>Why did my code didnt color the relevant rows please?</description>
      <pubDate>Mon, 15 May 2023 08:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875761#M346036</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-15T08:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875782#M346047</link>
      <description>&lt;P&gt;You don't have a DEFINE statement for IND_CHANGE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add this into your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define Ind_Change/noprint display;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you can use simple math to see if the values in MON1-MON6 are equal or not. In a data step use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Var_groups=2 and range(of mon:)&amp;gt;0 then Ind_Change=1;
else Ind_Change=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This data is not in "long structure", it is in wide structure.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 10:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875782#M346047</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-15T10:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color rows If there is change in value between specific columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875793#M346053</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data summary_Report_Long_Strcuture;
infile datalines delimiter=',';
Input  Var_name $  Var_groups $ Mon1 $ Mon2  $ Mon3 $ Mon4  $ Mon5 $ Mon6 $;
cards;
month,1,2210,2211,2212,2301,2302,2303
customer,1,777,777,777,777,777,777
branch,1,23,23,23,23,23,23
X1,2,a,a,a,a,a,a 
W1,2,1,1,1,2,1,1 
Z1,2,1,1,1,1,1,1 
X1,2,1,2,1,1,1,1 
;
Run;
proc report data=summary_Report_Long_Strcuture nowd;
compute Mon6;
array x{*} $ Mon1-Mon6;
if Var_groups='2' then do;
 do i=2 to dim(x);
 if x{1} ne x{i} then do;
   call define(_row_,'style','style={background=gold}');
   leave;
 end;
 end;
end;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1684150806446.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83976i5B63D8C9E6E6E2DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1684150806446.png" alt="Ksharp_0-1684150806446.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 11:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-rows-If-there-is-change-in-value-between/m-p/875793#M346053</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-15T11:40:09Z</dc:date>
    </item>
  </channel>
</rss>

