<?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 do I create a dataset from a Multidimensional Array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293050#M60919</link>
    <description>&lt;P&gt;Just a short code snippet to illustrate how one could write the contents of an array to a dataset; note that the dataset in question is always named in the data ...; statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1 (drop=i j);
array x{2,3};
do i = 1 to 2;
  do j = 1 to 3;
    x{i,j} = i*j;
  end;
end;
run;

proc print noobs;
run;

data test2 (keep=i j value);
array x{2,3};
do i = 1 to 2;
  do j = 1 to 3;
    x{i,j} = i*j;
    value = x{i,j};
    output;
  end;
end;
run;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This creates the following outputs:&lt;/P&gt;
&lt;PRE&gt;x1    x2    x3    x4    x5    x6

 1     2     3     2     4     6
                                

        i    j    value

        1    1      1  
        1    2      2  
        1    3      3  
        2    1      2  
        2    2      4  
        2    3      6  &lt;/PRE&gt;
&lt;P&gt;Also note that no input dataset was involved, which means both data steps underwent only 1 iteration. With an input dataset, everything would be repeated for each observation in the dataset.&lt;/P&gt;
&lt;P&gt;If you wanted to create a separate dataset for eacjh input observation, more complicated programming would be necessary; I could imagine solving that with the use of a hash object.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2016 07:23:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-08-22T07:23:08Z</dc:date>
    <item>
      <title>How do I create a dataset from a Multidimensional Array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293030#M60908</link>
      <description>&lt;P&gt;I have several multidimensional arrays created within a datastep. Is there an easy way to save these arrays as datasets outside of the datastep in which they have been created?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 01:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293030#M60908</guid>
      <dc:creator>lilam</dc:creator>
      <dc:date>2016-08-22T01:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a Multidimensional Array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293031#M60909</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt; A SAS Array is a convenient way to create a reference to a group of variables. So unless you defined your arrays as temporary, your variables are already stored in a SAS dataset, as variables.&lt;BR /&gt;&lt;BR /&gt; Let's say that you have an ARRAY statement like this in your program:&lt;BR /&gt;ARRAY ARR (5) v1 v2 v3 v4 v5; &lt;BR /&gt;or&lt;BR /&gt;ARRAY LL (4) $ lucy ricky fred ethel;&lt;BR /&gt;&lt;BR /&gt; So, depending on whether your variables exist already or whether you are creating them, the ARRAY statement gives you a way to reference the variables as though they were members of an ARRAY. But the ARRAY in SAS is for reference purposes only in a program; outside of the program, in your SAS dataset, the variable values are stored under the individual variable names.&lt;BR /&gt;&lt;BR /&gt; Please see this paper for a longer explanation:&lt;BR /&gt; &lt;A href="https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 02:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293031#M60909</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-08-22T02:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a Multidimensional Array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293035#M60912</link>
      <description>&lt;P&gt;Arrays in SAS are not objects they are simply a way to reference variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As Cynthia has indicated they'll be saved, but probably not in a format you want.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 02:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293035#M60912</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-22T02:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a dataset from a Multidimensional Array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293050#M60919</link>
      <description>&lt;P&gt;Just a short code snippet to illustrate how one could write the contents of an array to a dataset; note that the dataset in question is always named in the data ...; statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1 (drop=i j);
array x{2,3};
do i = 1 to 2;
  do j = 1 to 3;
    x{i,j} = i*j;
  end;
end;
run;

proc print noobs;
run;

data test2 (keep=i j value);
array x{2,3};
do i = 1 to 2;
  do j = 1 to 3;
    x{i,j} = i*j;
    value = x{i,j};
    output;
  end;
end;
run;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This creates the following outputs:&lt;/P&gt;
&lt;PRE&gt;x1    x2    x3    x4    x5    x6

 1     2     3     2     4     6
                                

        i    j    value

        1    1      1  
        1    2      2  
        1    3      3  
        2    1      2  
        2    2      4  
        2    3      6  &lt;/PRE&gt;
&lt;P&gt;Also note that no input dataset was involved, which means both data steps underwent only 1 iteration. With an input dataset, everything would be repeated for each observation in the dataset.&lt;/P&gt;
&lt;P&gt;If you wanted to create a separate dataset for eacjh input observation, more complicated programming would be necessary; I could imagine solving that with the use of a hash object.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 07:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-dataset-from-a-Multidimensional-Array/m-p/293050#M60919</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-22T07:23:08Z</dc:date>
    </item>
  </channel>
</rss>

