<?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: Macro variable with array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503460#M134527</link>
    <description>There are a lot of obs in the HAVE data set so there is a do-loop command right before that.</description>
    <pubDate>Thu, 11 Oct 2018 16:38:26 GMT</pubDate>
    <dc:creator>dera</dc:creator>
    <dc:date>2018-10-11T16:38:26Z</dc:date>
    <item>
      <title>Macro variable with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503455#M134523</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know how to define macro variables using the array function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what my code looks like :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_; set have;

array var {*} var_1-var_5;
do i = 1 to dim(var);
call symput ("var_(i)", (var_(i)));
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggestions on how I can improve it so that it works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 16:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503455#M134523</guid>
      <dc:creator>dera</dc:creator>
      <dc:date>2018-10-11T16:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503457#M134525</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236159"&gt;@dera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to define macro variables using the array function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is what my code looks like :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_; set have;

array var {*} var_1-var_5;
do i = 1 to dim(var);
call symput ("var_(i)", (var_(i)));
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any suggestions on how I can improve it so that it works?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you tell us what you are trying to do?&amp;nbsp; I can see you probably want to create 5 macro variables but if HAVE has more that one obs you will still only have the values from the last obs of have.&amp;nbsp; Maybe you don't need these macro variables at all.&amp;nbsp; When you start putting a lot of data into macro variables "things" get messy.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 16:35:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503457#M134525</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-11T16:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503460#M134527</link>
      <description>There are a lot of obs in the HAVE data set so there is a do-loop command right before that.</description>
      <pubDate>Thu, 11 Oct 2018 16:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503460#M134527</guid>
      <dc:creator>dera</dc:creator>
      <dc:date>2018-10-11T16:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable with array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503466#M134531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236159"&gt;@dera&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;There are a lot of obs in the HAVE data set so there is a do-loop command right before that.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe something like this but it is messy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   do id = 1 to 5;
      array var_[5];
      do i = 1 to dim(var_);
         var_[i] = ranuni(1);
         end;
      output;
      end;
   run;
data _null_; 
   set have;
   array var_[*] var_1-var_5;
   do i = 1 to dim(var_);
      call symputx(cats('ID_',id,'_',vname(var_[i])),var_[i],'G');
      end;
   run;
%put _global_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;239  %put _global_;
GLOBAL ID_1_VAR_1 0.1849625698
GLOBAL ID_1_VAR_2 0.9700887157
GLOBAL ID_1_VAR_3 0.3998243061
GLOBAL ID_1_VAR_4 0.2593986454
GLOBAL ID_1_VAR_5 0.9216025779
GLOBAL ID_2_VAR_1 0.9692773498
GLOBAL ID_2_VAR_2 0.5429791731
GLOBAL ID_2_VAR_3 0.5316917228
GLOBAL ID_2_VAR_4 0.0497940262
GLOBAL ID_2_VAR_5 0.0665665516
GLOBAL ID_3_VAR_1 0.8193185706
GLOBAL ID_3_VAR_2 0.5238705215
GLOBAL ID_3_VAR_3 0.8533943109
GLOBAL ID_3_VAR_4 0.0671845768
GLOBAL ID_3_VAR_5 0.9570238576
GLOBAL ID_4_VAR_1 0.2971939642
GLOBAL ID_4_VAR_2 0.2726117891
GLOBAL ID_4_VAR_3 0.6899296309
GLOBAL ID_4_VAR_4 0.9767648624
GLOBAL ID_4_VAR_5 0.2265075185
GLOBAL ID_5_VAR_1 0.6882365503
GLOBAL ID_5_VAR_2 0.4127638663
GLOBAL ID_5_VAR_3 0.5585541127
GLOBAL ID_5_VAR_4 0.2872256107
GLOBAL ID_5_VAR_5 0.475789305
GLOBAL ID_6_VAR_1 0.6882365503
GLOBAL ID_6_VAR_2 0.4127638663
GLOBAL ID_6_VAR_3 0.5585541127
GLOBAL ID_6_VAR_4 0.2872256107
GLOBAL ID_6_VAR_5 0.475789305
&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 16:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-with-array/m-p/503466#M134531</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-11T16:48:13Z</dc:date>
    </item>
  </channel>
</rss>

