<?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: Array in Proc Report to color in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546659#M151391</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Afaik arrays are only available in the data step.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the past, I have used arrays in a PROC REPORT compute block, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array c _c3_ _c4_ _c5_ _c6_ _c7_ _c8_ _c9_ _c10_;
do i=1 to dim(c);
    if c{i}&amp;lt;20000 then call define(i+2,'style','style={background=yellow}');
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, the original poster&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;could adapt this to his problem.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 19:45:39 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-03-27T19:45:39Z</dc:date>
    <item>
      <title>Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546558#M151335</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 2 sets of column, One set start with S_ and the other set start with V_&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is that I create 2 arrays and perform the coloring as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Array S(*) S_:;&lt;/P&gt;
&lt;P&gt;Array V(*) V_:;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do i=1 to Dim(S);&lt;/P&gt;
&lt;P&gt;if S(i)&amp;gt;V(i) then color the S(i) cell.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me fixing my code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID S_axb S_a V_a V_acb ;
datalines;
1 1 1 1 1
2 1 2 1 0
3 1 2 3 1
4 9 8 7 4
;run;

proc report data=Have nowd;

  define S:/display;
  define V:/display;
  define dummy/display;

  compute dummy;
	 array v(*) V:;
	 array s(*) S:;
	 dummy=1;


	 do i=1 to dim(v);
		 if v{i}&amp;gt;s{i} then call define ("v{i}","style","style={background=RED}");
	 end;
  endcomp;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546558#M151335</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-27T15:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546599#M151356</link>
      <description>&lt;P&gt;Afaik arrays are only available in the data step.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 17:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546599#M151356</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-27T17:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546619#M151367</link>
      <description>&lt;P&gt;You need a column statement in order to get compute dummy to work.&amp;nbsp; Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID S_axb S_a V_a V_acb ;
datalines;
1 1 1 1 1
2 1 2 1 0
3 1 2 3 1
4 9 8 7 4
;;;;

data _null_;
set have; 
  array v(*) V:;
  array s(*) S:;
  do i = 1 to dim(v); 
    v_Element=vname(v{i}); 
	s_Element=vname(s{i});
   file "!TEMP\define.sas" ;
	put 'define ' s_Element '/ display ;' 
	  / 'define ' v_Element '/ display ;';
   file  "!TEMP\compute.sas" ;
	put 'if ' v_Element '&amp;gt; ' s_Element 'then call define ("' v_Element +(-1)'","style","style={background=RED}");' ;
  end; 
stop; run;

proc report data=Have nowd;
column _ALL_ dummy;
%include "!TEMP\define.sas"  /source2;
  define dummy / noprint;

  compute dummy;
	 dummy=1;
     %include "!TEMP\compute.sas"  /source2;
  endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 17:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546619#M151367</guid>
      <dc:creator>JerryV</dc:creator>
      <dc:date>2019-03-27T17:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546659#M151391</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Afaik arrays are only available in the data step.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In the past, I have used arrays in a PROC REPORT compute block, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array c _c3_ _c4_ _c5_ _c6_ _c7_ _c8_ _c9_ _c10_;
do i=1 to dim(c);
    if c{i}&amp;lt;20000 then call define(i+2,'style','style={background=yellow}');
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, the original poster&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;could adapt this to his problem.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 19:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546659#M151391</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-27T19:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546682#M151399</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;: thanks ... I should have looked it up before posting.</description>
      <pubDate>Wed, 27 Mar 2019 20:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546682#M151399</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-27T20:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546702#M151412</link>
      <description>&lt;P&gt;I cant fix the issue of declaring array.&lt;/P&gt;
&lt;P&gt;I try another way but still fail.&lt;/P&gt;
&lt;P&gt;I hope to be able to do it in an easy to understand way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=Have nowd;

  define S:/display;
  define V:/display;

	 array v(*) V:;
	 array s(*) S:;


	 do i=1 to dim(v);
		compute v{i};
			 if v{i}&amp;gt;s{i} then call define ("v{i}","style","style={background=RED}");
	  	endcomp;
	 end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 20:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546702#M151412</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-27T20:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546707#M151417</link>
      <description>&lt;P&gt;I simplify everything and the issue is the declare of Array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;50636 proc report data=Have nowd;&lt;BR /&gt;50637&lt;BR /&gt;50638 define V:/display;&lt;BR /&gt;50639&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;50640 array v(*) V:;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;-----&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;180&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/FONT&gt;&lt;BR /&gt;50641&lt;BR /&gt;50642 do i=1 to dim(v);&lt;BR /&gt;--&lt;BR /&gt;180&lt;BR /&gt;50643 compute v{i};&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;200&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, /.&lt;BR /&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;50644 if v{i}&amp;gt;0 then call define (i,"style","style={background=RED}");&lt;BR /&gt;50645 endcomp;&lt;BR /&gt;50646 end;&lt;BR /&gt;---&lt;BR /&gt;180&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;50647&lt;BR /&gt;50648 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE REPORT used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID S_axb S_a V_a V_acb ;
datalines;
1 1 1 1 1
2 1 2 1 0
3 1 2 3 1
4 9 8 7 4
;run;

proc report data=Have nowd;

  define V:/display;

	 array v(*) V:;

	 do i=1 to dim(v);
		compute v{i};
			 if v{i}&amp;gt;0 then call define (i,"style","style={background=RED}");
	  	endcomp;
	 end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546707#M151417</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-27T21:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546759#M151443</link>
      <description>&lt;P&gt;OK, after hours of debug, here is the thing:&lt;/P&gt;
&lt;P&gt;In array, you have to list all variable. V: will not work!&lt;/P&gt;
&lt;P&gt;Somehow, I cant get the dummy=1 inside the Proc Report works. So I just create this dummy in the data have.&lt;/P&gt;
&lt;P&gt;To get column painted, I use the &lt;CODE class=" language-sas"&gt;thisvar=vname(v(i)); and put thisvar in define statement.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's all I can say.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes Array works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID S_axb S_a V_a V_acb ;
datalines;
1 1 1 1 1
2 1 2 1 0
3 1 2 3 1
4 9 8 7 4
;run;

data have ; set have;
dummy=1;run;

proc report data=Have nowd;
column S: V: dummy;&lt;BR /&gt;define dummy/display;&lt;BR /&gt;define V:/display;&lt;BR /&gt;define S:/display;


	compute dummy;
		length thisvar $10;
	 	array v(*) V_a V_acb;
	 	array s(*) S_axb S_a;

		do i=1 to dim(v);
			thisvar=vname(v(i));
			if V[i]&amp;lt;S(i) then call define (thisvar,"style","style={background=RED}");
		end;
	endcomp;

run;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 23:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546759#M151443</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-27T23:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Array in Proc Report to color</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546761#M151444</link>
      <description>&lt;P&gt;A bit more, put 2 list of name into macro variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID S_axb S_a V_a V_acb ;
datalines;
1 1 1 1 1
2 1 2 1 0
3 1 2 3 1
4 9 8 7 4
;run;

data have ; set have;
dummy=1;run;

/*create macro variable for list of column*/
%let var_list1= V_a V_acb;
%let var_list2= S_axb S_a;

data _v; set have;
keep V:;
if _N_=1;run;

proc transpose data=_v out=_v (keep=_NAME_);run;
proc sql noprint;
select _NAME_ into :varlist1 separated by ' ' from _v;quit;
%put &amp;amp;varlist1;


data _s; set have;
keep s:;
if _N_=1;run;

proc transpose data=_s out=_s (keep=_NAME_);run;
proc sql noprint;
select _NAME_ into :varlist2 separated by ' ' from _s;quit;
%put &amp;amp;varlist2;


proc report data=Have nowd;
  column  S: V: dummy;
	define dummy/display;
	define V:/display;
	define S:/display;



	compute dummy;
		length thisvar $10;
	 	array v(*) &amp;amp;var_list1;
	 	array s(*) &amp;amp;var_list2;

		do i=1 to dim(v);
			thisvar=vname(v(i));
			if V[i]&amp;gt;S(i) then call define (thisvar,"style","style={background=RED}");
		end;
	endcomp;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 00:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-in-Proc-Report-to-color/m-p/546761#M151444</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2019-03-28T00:02:41Z</dc:date>
    </item>
  </channel>
</rss>

