<?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: arrays efficiency problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122120#M25035</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The real job envolved 1 million observation and 10 arrays, each array has a size of 5000. So by elimiating one array (econ, which is a random economic variable shared by all observations) helps to reduce the size dramatically. 'SAS help' provided me a solution (Please see 3. Re.) which is exactly what I mean to do.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Sep 2012 19:58:09 GMT</pubDate>
    <dc:creator>Weihong</dc:creator>
    <dc:date>2012-09-14T19:58:09Z</dc:date>
    <item>
      <title>arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122115#M25030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the following code works fine. but when I increase the &amp;amp;col = 5000, it becomes very redundant. Any suggestions that I can do something like symput so save some space?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let row = 10;&lt;/P&gt;&lt;P&gt;%let col = 5;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to &amp;amp;row.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array econ econ_1 - econ_&amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array z z_1 - z_&amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 to &amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ = 1 then econ{j} = rannor(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z{j} = econ{j} * i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain econ_1 - econ_&amp;amp;col.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 14:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122115#M25030</guid>
      <dc:creator>Weihong</dc:creator>
      <dc:date>2012-09-14T14:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122116#M25031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One minor point if you only have one input set then _N_ will only be one once so there is no reaso to include that test in the DO J= loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sounds like you have a varying number of econ variables and you are sometimes creating extra variables that you don't want.&lt;/P&gt;&lt;P&gt;A quick and dirty approach would be to set COL using the data assuming you have a dataset with more meaningful ECON variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (obs=1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array econ econ_: ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x= dim(econ);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('col',put(x,f5.0));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 15:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122116#M25031</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-09-14T15:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122117#M25032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;"&lt;SPAN style="text-decoration: underline;"&gt;One minor point if you only have one input set then _N_ will only be one once so there is no reaso to include that test in the DO J= loop."&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Not quite understand what you mean here. The input data test1 has 10 observations. And, _N_ will be used 5 times as there are 5 arrays being created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;"It sounds like you have a varying number of econ variables and you are sometimes creating extra variables that you don't want."&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I do want to use those retained observations, but since they are all the same within same econ_*, it is redundent and it takes too much space. So I am thinking if I can write these 5 (&amp;amp;col.) econ_* as global variables, and retreat them when I need them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 15:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122117#M25032</guid>
      <dc:creator>Weihong</dc:creator>
      <dc:date>2012-09-14T15:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122118#M25033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got help from SAS already. See below code. Appreciate your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let col = 3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to &amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ('econ_'||strip(i), rannor(1));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array z z_1 - z_&amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do j = 1 %to &amp;amp;col.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z{&amp;amp;j} = &amp;amp;&amp;amp;econ_&amp;amp;j. *i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 19:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122118#M25033</guid>
      <dc:creator>Weihong</dc:creator>
      <dc:date>2012-09-14T19:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122119#M25034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought your data was to simulate something in lieue of your actual data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know what you mean by redundant or what space you want to save.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not want variables in the output data set but need them for calculations during the execution of the data set then drop them from the output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test2 (drop= econ_: ) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;may be what your are looking for.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 19:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122119#M25034</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-09-14T19:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: arrays efficiency problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122120#M25035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The real job envolved 1 million observation and 10 arrays, each array has a size of 5000. So by elimiating one array (econ, which is a random economic variable shared by all observations) helps to reduce the size dramatically. 'SAS help' provided me a solution (Please see 3. Re.) which is exactly what I mean to do.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Sep 2012 19:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/arrays-efficiency-problem/m-p/122120#M25035</guid>
      <dc:creator>Weihong</dc:creator>
      <dc:date>2012-09-14T19:58:09Z</dc:date>
    </item>
  </channel>
</rss>

