<?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 red/Green better/worse +ignore missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877056#M346473</link>
    <description>&lt;P&gt;Sure. You changed the structure of the data (specifically you removed a column) that was provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;in your &lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-from-month-to-month/m-p/876741#M346354" target="_self"&gt;earlier thread&lt;/A&gt;, and the code has to change as well to reflect the different data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the data from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Input VAR_name $ Mon2301 Mon2302 Mon2303 Mon2304 Mon2305;
cards;
X1 70 70 70 70 70
X2 70 70 90 90 90
X3 40 40 40 40 40
X4 30 30 50 50 20
X5 70 45 45 45 45
X6 30 30 30 20 40
TOTAL 310 285 325 315 305
Y 7 6 9 9 7
;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the data you provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines delimiter=',';
input mon1 mon2 mon3 mon4 ;
cards;
1,.,2,2
4,.,.,1
3,4,1,1
5,3,3,1
6,2,4,5
;&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;There's an important difference here, that your data has no identifier in the first column. Earlier there was an identifier variable. So, without the identifier variable, you need to modify the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; set vname(firstobs=2) end=last;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is no longer correct. The firstobs=2 removes the identifier variable name from the list of variable names.&amp;nbsp; Since you don't have an identifier variable, what change would you need to make to the above?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 12:23:06 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-23T12:23:06Z</dc:date>
    <item>
      <title>Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877043#M346463</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create proc report and display the data and apply color by following rule:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If there is increase from one month to next month then color it in red.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If there is decrease from one month to next month then color it in green.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If in one month have null value and next month non-null value then DON'T&amp;nbsp; color it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What is the way to&amp;nbsp; do it please?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;expected result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1684838584002.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84202i61A5ADE18CBADEEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1684838584002.png" alt="Ronein_0-1684838584002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is raw data and my try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines delimiter=',';
input mon1 mon2 mon3 mon4 ;
cards;
1,.,2,2
4,.,.,1
3,4,1,1
5,3,3,1
6,2,4,5
;
Run;

proc transpose data=have(obs=0) out=vname;
var _all_;
run;


data _null_;
set vname(firstobs=2) end=last;
length list $ 2000;
retain list;
list=catx(' ',list,_name_);
if last then do;
  call symputx('list',list);
  call symputx('last',_name_);
end;
run;
%put &amp;amp;list.;
%put &amp;amp;last.;


proc report data=have nowd;
define _all_/display;
compute &amp;amp;last.;
array x{*} &amp;amp;list. ;
do i=2 to dim(x);
if x{i}&amp;gt;x{i-1} then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1} then call define(vname(x{i}),'style','style={background=green}');
end;
endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 10:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877043#M346463</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-23T10:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877045#M346464</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x{i}&amp;gt;x{i-1} then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1} then call define(vname(x{i}),'style','style={background=green}');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can modify these IF statements to ignore the case where one month is null and the next month is not null. Please try it and show us what you have come up with.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 11:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877045#M346464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-23T11:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877049#M346467</link>
      <description>&lt;P&gt;Sure, I know that the code modification should be done&amp;nbsp; here&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x{i}&amp;gt;x{i-1} then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1} then call define(vname(x{i}),'style','style={background=green}');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The question is how to do it&lt;/P&gt;
&lt;P&gt;I tried this code but it didnt work well&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x{i}&amp;gt;x{i-1} AND x{i-1} ne . then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1}  AND x{i-1} ne . then call define(vname(x{i}),'style','style={background=green}');
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 11:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877049#M346467</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-23T11:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877050#M346468</link>
      <description>&lt;P&gt;What about it didn't work? Explain.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 11:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877050#M346468</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-23T11:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877053#M346470</link>
      <description>&lt;P&gt;some cells should be colored&amp;nbsp; but in my code they are not&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1684841694929.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84203iCED2AF9D6D0AB891/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1684841694929.png" alt="Ronein_0-1684841694929.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 11:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877053#M346470</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-23T11:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877056#M346473</link>
      <description>&lt;P&gt;Sure. You changed the structure of the data (specifically you removed a column) that was provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;in your &lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-from-month-to-month/m-p/876741#M346354" target="_self"&gt;earlier thread&lt;/A&gt;, and the code has to change as well to reflect the different data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the data from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Input VAR_name $ Mon2301 Mon2302 Mon2303 Mon2304 Mon2305;
cards;
X1 70 70 70 70 70
X2 70 70 90 90 90
X3 40 40 40 40 40
X4 30 30 50 50 20
X5 70 45 45 45 45
X6 30 30 30 20 40
TOTAL 310 285 325 315 305
Y 7 6 9 9 7
;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the data you provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines delimiter=',';
input mon1 mon2 mon3 mon4 ;
cards;
1,.,2,2
4,.,.,1
3,4,1,1
5,3,3,1
6,2,4,5
;&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;There's an important difference here, that your data has no identifier in the first column. Earlier there was an identifier variable. So, without the identifier variable, you need to modify the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; set vname(firstobs=2) end=last;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is no longer correct. The firstobs=2 removes the identifier variable name from the list of variable names.&amp;nbsp; Since you don't have an identifier variable, what change would you need to make to the above?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 12:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877056#M346473</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-23T12:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877111#M346504</link>
      <description>&lt;P&gt;Still result is not as desired&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1684858431317.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84208iF6DED5CB0CFF3373/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1684858431317.png" alt="Ronein_0-1684858431317.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines delimiter=',';
input mon1 mon2 mon3 mon4 ;
cards;
1,.,2,2
4,.,.,1
3,4,1,1
5,3,3,1
6,2,4,5
;
Run;

proc transpose data=have(obs=0) out=vname;
var _all_;
run;


data _null_;
set vname(firstobs=1) end=last;
length list $ 2000;
retain list;
list=catx(' ',list,_name_);
if last then do;
  call symputx('list',list);
  call symputx('last',_name_);
end;
run;
%put &amp;amp;list.;
%put &amp;amp;last.;


proc report data=have nowd;
define _all_/display;
compute &amp;amp;last.;
array x{*} &amp;amp;list. ;
do i=2 to dim(x);
if x{i}&amp;gt;x{i-1} AND x{i-1} ne . then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1}  AND x{i-1} ne . then call define(vname(x{i}),'style','style={background=green}');
end;
endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 16:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877111#M346504</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-23T16:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report-Color red/Green better/worse +ignore missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877113#M346505</link>
      <description>&lt;P&gt;This code provide the solution,thanks&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines delimiter=',';
input mon1 mon2 mon3 mon4 ;
cards;
1,.,2,2
4,.,.,1
3,4,1,1
5,3,3,1
6,2,4,5
;
Run;

proc transpose data=have(obs=0) out=vname;
var _all_;
run;


data _null_;
set vname(firstobs=1) end=last;
length list $ 2000;
retain list;
list=catx(' ',list,_name_);
if last then do;
  call symputx('list',list);
  call symputx('last',_name_);
end;
run;
%put &amp;amp;list.;
%put &amp;amp;last.;


proc report data=have nowd;
define _all_/display;
compute &amp;amp;last.;
array x{*} &amp;amp;list. ;
do i=2 to dim(x);
if x{i}&amp;gt;x{i-1} AND x{i-1} ne . and x{i} ne . then call define(vname(x{i}),'style','style={background=red}');
if x{i}&amp;lt;x{i-1}  AND x{i-1} ne . and x{i} ne . then call define(vname(x{i}),'style','style={background=green}');
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="Ronein_0-1684858527059.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84209i4398F0C3B5A3B1EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1684858527059.png" alt="Ronein_0-1684858527059.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 16:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-Color-red-Green-better-worse-ignore-missing-values/m-p/877113#M346505</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-23T16:15:42Z</dc:date>
    </item>
  </channel>
</rss>

