<?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 Can arrays be used in PROC REPORT with an ACROSS variable? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875509#M26295</link>
    <description>&lt;P&gt;In this thread&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-report-with-same-compute-block-for-many/m-p/873801#M345225" target="_blank"&gt;Use of ARRAY in PROC REPORT COMPUTE block&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; shows how to use array statements in a compute block in PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can something similar be used if there is an ACROSS variable? For example, in this code, could I create an ARRAY in a COMPUTE block and then have it work on all three columns of the variable ORIGIN to turn some cells green or yellow in those 3 columns?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.cars;
    columns cylinders origin,mpg_city;
    define cylinders/group;
    define origin/across;
    define mpg_city/mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 May 2023 19:07:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-12T19:07:05Z</dc:date>
    <item>
      <title>Can arrays be used in PROC REPORT with an ACROSS variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875509#M26295</link>
      <description>&lt;P&gt;In this thread&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-report-with-same-compute-block-for-many/m-p/873801#M345225" target="_blank"&gt;Use of ARRAY in PROC REPORT COMPUTE block&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; shows how to use array statements in a compute block in PROC REPORT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can something similar be used if there is an ACROSS variable? For example, in this code, could I create an ARRAY in a COMPUTE block and then have it work on all three columns of the variable ORIGIN to turn some cells green or yellow in those 3 columns?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.cars;
    columns cylinders origin,mpg_city;
    define cylinders/group;
    define origin/across;
    define mpg_city/mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2023 19:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875509#M26295</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-12T19:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can arrays be used in PROC REPORT with an ACROSS variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875514#M26296</link>
      <description>&lt;P&gt;It is a matter of figuring out how PROC REPORT will name the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.cars out=test;
    columns cylinders origin,mpg_city a;
    define cylinders/group;
    define origin/across;
    define mpg_city/mean;
	define a / computed;
    compute a;
	   array _x _C2_ _C3_ _C4_;
	   a = sum(of _x[*]);
	   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="Capture.PNG" style="width: 414px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83925i5C5AAD0E6A6EDC62/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 384px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83926iCDFA012343BB2BC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 19:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875514#M26296</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2023-05-12T19:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can arrays be used in PROC REPORT with an ACROSS variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875534#M26297</link>
      <description>&lt;P&gt;Okay, thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt; , that works!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.cars out=test;
    columns cylinders origin,mpg_city dummy;
    define cylinders/group;
    define origin/across;
    define mpg_city/mean;
	define dummy / computed noprint;
    compute dummy;
	   array _x _C2_ _c3_ _C4_;
	   do i=1 to dim(_x);
	       if _x{i}&amp;gt;15 and _x{i}&amp;gt;0 then call define(vname(_x{i}),'style','style=[background=lightmoderategreen]');
	       else if _x{i}&amp;gt;0 then call define(vname(_x{i}),'style','style=[background=lightmoderatered]');
       end;
	   endcomp;
	run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but now here's a related problem that I need to solve — suppose the across variable has 50 levels. Do I have to type all 50 _c2_ through _c51_ in the ARRAY statement, or is there an easier way to do this? I tried using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array _x _C2_--_C51_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but that produces an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I realize I can use a macro here if I need to to create all 50 variable names, I'm hoping there's another way.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 21:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875534#M26297</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-12T21:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can arrays be used in PROC REPORT with an ACROSS variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875537#M26298</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro colarray(s,n);
   %local i;
   %do i = &amp;amp;s %to &amp;amp;n;
      _C&amp;amp;n._
      %end;
   %mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SAS-Variable lists don't work I reckon because the data loop part of PROC REPORT doesn't know those names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Added start parameter.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 12:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Can-arrays-be-used-in-PROC-REPORT-with-an-ACROSS-variable/m-p/875537#M26298</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2023-05-15T12:36:21Z</dc:date>
    </item>
  </channel>
</rss>

