<?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: How to output two dimensional array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752487#M237047</link>
    <description>Thanks Astounding, but what if I want the 0,1 to be character not numeric? In fact you could change the '0'to '@'</description>
    <pubDate>Wed, 07 Jul 2021 03:47:57 GMT</pubDate>
    <dc:creator>simmwa</dc:creator>
    <dc:date>2021-07-07T03:47:57Z</dc:date>
    <item>
      <title>How to output two dimensional array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752480#M237042</link>
      <description>&lt;P&gt;I want to use proc print or something to display a table like this below. I have been trying to use arrays, but maybe I'm on the wrong track.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;aaa&lt;/TD&gt;&lt;TD&gt;bbb&lt;/TD&gt;&lt;TD&gt;ccc&lt;/TD&gt;&lt;TD&gt;ddd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;eee&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fff&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ggg&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code so far which doesnt work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=C1-C12);
	array fname {4} $ 3 ('aaa', 'bbb', 'ccc', 'ddd');
	array sname {3} $ 3 ('eee', 'fff', 'ggg');
	array C3SP {4,3} $ 1 C1-C12;

do i = 1 to 4;
		do j = 1 to 3;
			if sname[j] in ('fff', 'ggg') and fname[i] = 'bbb' then myname = '1';
			else myname= '0';
			C3SP[i,j] = myname;
			put C3SP[i,j]=;
			output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 02:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752480#M237042</guid>
      <dc:creator>simmwa</dc:creator>
      <dc:date>2021-07-07T02:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to output two dimensional array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752486#M237046</link>
      <description>&lt;P&gt;It's not how you approached the problem, but this should get you close:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   do rows = 'eee', 'fff', 'ggg';
      do cols = 'aaa', 'bbb', 'ccc', 'ddd';
         if cols='bbb' and rows in ('fff', 'ggg') then value=1;
         else value=0;
         output;
      end;
   end;
run;
proc tabulate data=want;
   var value;
   class rows cols;
   tables rows, cols*value=' '*sum=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jul 2021 03:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752486#M237046</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-07-07T03:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to output two dimensional array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752487#M237047</link>
      <description>Thanks Astounding, but what if I want the 0,1 to be character not numeric? In fact you could change the '0'to '@'</description>
      <pubDate>Wed, 07 Jul 2021 03:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752487#M237047</guid>
      <dc:creator>simmwa</dc:creator>
      <dc:date>2021-07-07T03:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to output two dimensional array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752489#M237048</link>
      <description>&lt;P&gt;You may have a wrong understanding what arrays are in sas: they exist primary to access variables of same type that need to be processed in the same way. The result you show looks like a report, not like a dataset at all. Another idea: have a look at proc iml, i have hardly used it, but it is the tool in sas to work with matrices.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 04:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752489#M237048</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-07T04:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to output two dimensional array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752493#M237050</link>
      <description>&lt;P&gt;Not completely sure why, but this mod seems to work. Thanks !!!&lt;/P&gt;&lt;P&gt;&lt;A title="Proc Tabulate - Using a character variable in the VAR Statement" href="https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-Tabulate-Using-a-character-variable-in-the-VAR-Statement/m-p/296012#M16777" target="_self"&gt;Proc Tabulate - Using a character variable in the VAR Statement&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; proc format library=work;
invalue mtype
   '@'  = 1
   '&amp;amp;'  = 2
   '%'  = 3
;
value mtype
   1 = '@'
   2 = '&amp;amp;'
   3 = '%'
;
run;

data wantdev3;
   informat myname mtype.;
   format   myname mtype.;
	do rows = 'aaa', 'bbb', 'ccc', 'ddd';
		do cols = 'eee', 'fff', 'ggg';
			if cols in ('fff', 'ggg') and rows = 'bbb' then myname = 1;
			else myname= 2;
			output;
		end;
	end;
run;
proc tabulate data=wantdev3 ;
	var myname;
	class rows cols;
	table rows, cols*myname=' '*sum=' '*f=mtype.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jul 2021 05:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-two-dimensional-array/m-p/752493#M237050</guid>
      <dc:creator>simmwa</dc:creator>
      <dc:date>2021-07-07T05:55:39Z</dc:date>
    </item>
  </channel>
</rss>

