<?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: Array Do Loop using macro from INTO: cluase in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250197#M17683</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38914"&gt;@koomalkc﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data step information such as dim(n)&amp;nbsp;is unavailable to macro statements (here: %DO), because macro statements are resolved before the data step is even compiled. You can simply use a data step DO-loop instead of a macro %DO-loop there.&amp;nbsp;Hence, there is no longer a need for wrapping your code into a macro at all, so you can delete the %MACRO, %MEND and %USE statements altogether.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Feb 2016 21:49:13 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-02-15T21:49:13Z</dc:date>
    <item>
      <title>Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250192#M17681</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;use&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;proc contents data=check(drop=y) out=_out;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;select distinct name into: list separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from _out;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; the value of &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%nrstr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;list):&amp;amp;list;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;data naya;&lt;/P&gt;
&lt;P&gt;set check;&lt;/P&gt;
&lt;P&gt;array n{*} &amp;amp;list;&lt;/P&gt;
&lt;P&gt;array x{*} _numeric_;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i= &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; dim(n);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;n{i}=(x({i}=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; use;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;options&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;mprint&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;mlogic&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;symbolgen&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;use&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;/*********************************************/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Hi All,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I'm trying to use list of variables which are created using proc sql INTO: in to array do loop SAS code, but I have encountered following ERRORS:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ERROR: &lt;/FONT&gt;&lt;FONT color="#ff0000" face="Courier New" size="3"&gt;Required&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; operator not found in expression: dim(n) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;ERROR: The &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%TO&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; value of the &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%DO&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; I loop is &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;invalid.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Any suggestion, helps are highly appreciated.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Thanks!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 21:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250192#M17681</guid>
      <dc:creator>koomalkc</dc:creator>
      <dc:date>2016-02-15T21:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250197#M17683</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38914"&gt;@koomalkc﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data step information such as dim(n)&amp;nbsp;is unavailable to macro statements (here: %DO), because macro statements are resolved before the data step is even compiled. You can simply use a data step DO-loop instead of a macro %DO-loop there.&amp;nbsp;Hence, there is no longer a need for wrapping your code into a macro at all, so you can delete the %MACRO, %MEND and %USE statements altogether.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 21:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250197#M17683</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-15T21:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250210#M17685</link>
      <description>&lt;P&gt;On a separate note, it's a little strange to see two arrays here. &amp;nbsp;For the program to work at all (assuming the current error is worked through), the data set CHECK must contain only a single character variable named "Y". &amp;nbsp;Otherwise the dimensions of the two arrays will be different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your intent to replace the original numeric variables with new values (1 for missing, 0 for nonmissing)? &amp;nbsp;In that case you would only need one array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is your intent to create a new set of variables with these 0/1 values? &amp;nbsp;In that case, you need to do some more work to count and name a new set of variables.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 23:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250210#M17685</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-02-15T23:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250270#M17689</link>
      <description>&lt;P&gt;Post some test data in the form of a datastep, and what you want the output to look like. &amp;nbsp;I don't see any need for any macro code here, just do it in base SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 09:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250270#M17689</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-16T09:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250272#M17691</link>
      <description>&lt;P&gt;What are you trying to accomplish with this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;n{i}=(x({i}=.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;It is at least syntactically incorrect by missing a closing paranthesis.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 09:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250272#M17691</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-16T09:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array Do Loop using macro from INTO: cluase</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250351#M17692</link>
      <description>&lt;P&gt;If you were by some chance expecting to loop over the number elements created here:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;select distinct name into: list separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from _out;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; the value of &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%nrstr&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;list):&amp;amp;list;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may help IF EACH NAME is a single word that you can get a count :&lt;/P&gt;
&lt;P&gt;%let namecount= %sysfunc(countw,&amp;amp;list,' '));&lt;/P&gt;
&lt;P&gt;And use &amp;amp;namecount for the loop control.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Especially if you intended&lt;/P&gt;
&lt;P&gt;Array n &amp;amp;list;&lt;/P&gt;
&lt;P&gt;to declare an array consisting of variable names.&lt;/P&gt;
&lt;P&gt;Of course you may have an issue with numeric and character variables as you can't mix those in a single array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want to do something to all of the numeric variables:&lt;/P&gt;
&lt;P&gt;Data naya;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set check;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; array n _numeric_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do i = 1 to dim(n);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Similar you could declare an additional array of _character_ and no macro is needed at all.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 15:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Array-Do-Loop-using-macro-from-INTO-cluase/m-p/250351#M17692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-16T15:24:54Z</dc:date>
    </item>
  </channel>
</rss>

