<?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: problem in macro... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695648#M212308</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CALL SYMPUT('N', DIM(VAR));
%DO I = 1 %TO &amp;amp;N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You set the macro variable during the&amp;nbsp;&lt;EM&gt;data step execution phase&lt;/EM&gt;, but try to use it in a macro statement that is resolved during the&amp;nbsp;&lt;EM&gt;data step compilation phase&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;Use a data step loop instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('N', dim(var));
do i = 1 to dim(var);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 31 Oct 2020 13:02:41 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-10-31T13:02:41Z</dc:date>
    <item>
      <title>problem in macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695646#M212306</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a macro for binning variables data set through do loop in SAS BASE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&amp;nbsp;BIN();&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;SET TMP;&lt;/P&gt;&lt;P&gt;ARRAY VAR {*} _ALL_;&lt;/P&gt;&lt;P&gt;CALL SYMPUT('N', DIM(VAR));&lt;/P&gt;&lt;P&gt;%DO I = &lt;STRONG&gt;1&lt;/STRONG&gt; %TO &amp;amp;N;&lt;/P&gt;&lt;P&gt;CALL SYMPUT('VN', VNAME(VAR{&amp;amp;I}));&lt;/P&gt;&lt;P&gt;CALL EXECUTE('PROC RANK DATA = TMP(KEEP = &amp;amp;VN) OUT = &amp;amp;VN._BIN GROUPS = 5 TIES = DENSE;' || 'VAR &amp;amp;VN;' || 'RUN;' );&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&amp;nbsp;BIN;&lt;/P&gt;&lt;P&gt;%BIN();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Binning was done but a macro was not stop until I canceled by using task manager.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What was a problem in my code?&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2020 12:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695646#M212306</guid>
      <dc:creator>opuyfb91</dc:creator>
      <dc:date>2020-10-31T12:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: problem in macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695648#M212308</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CALL SYMPUT('N', DIM(VAR));
%DO I = 1 %TO &amp;amp;N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You set the macro variable during the&amp;nbsp;&lt;EM&gt;data step execution phase&lt;/EM&gt;, but try to use it in a macro statement that is resolved during the&amp;nbsp;&lt;EM&gt;data step compilation phase&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;Use a data step loop instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('N', dim(var));
do i = 1 to dim(var);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 31 Oct 2020 13:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695648#M212308</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-31T13:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: problem in macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695653#M212312</link>
      <description>&lt;P&gt;Assuming you get the logic errors worked out, so that you get even one PROC RANK to work properly ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program will run a long time because it generates many more PROC RANKs than you are expecting.&amp;nbsp; SET TMP reads in the first observation, and then CALL EXECUTE generates PROC RANK for every variable.&amp;nbsp; Then SET TMP reads in the second observation and CALL EXECUTE generates the same set of PROC RANKs over again (one for every variable).&amp;nbsp; With 50 variables and 1,000 observations, you are not asking for 50 PROC RANKs.&amp;nbsp; Instead, you are getting 50,000 PROC RANKs.&amp;nbsp; You would need to add a STOP statement just before the RUN statement.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Oct 2020 15:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-macro/m-p/695653#M212312</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-10-31T15:07:32Z</dc:date>
    </item>
  </channel>
</rss>

