<?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 Loop issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40233#M8160</link>
    <description>Hi SPR,&lt;BR /&gt;
I have SAS Enterprise Guide 4.1 (4.1.0.1016). Do you know if different versions of EG can cause such issues? I was thinking the macro quoting functions are pretty much standard, arent they?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert.</description>
    <pubDate>Wed, 30 Mar 2011 15:48:35 GMT</pubDate>
    <dc:creator>saspert</dc:creator>
    <dc:date>2011-03-30T15:48:35Z</dc:date>
    <item>
      <title>Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40228#M8155</link>
      <description>Hello,&lt;BR /&gt;
I am using this sample note by SAS to loop through a set of character values. The original macro loop works fine but not sure why mine does not.&lt;BR /&gt;
&lt;BR /&gt;
DATA METRICS;&lt;BR /&gt;
LENGTH MT $25;&lt;BR /&gt;
INPUT MT ;&lt;BR /&gt;
CARDS;&lt;BR /&gt;
TOT_COMP_PGM&lt;BR /&gt;
REG_MEM&lt;BR /&gt;
BIO_SCREEN&lt;BR /&gt;
FAX_MAIL_BIO_SCREEN&lt;BR /&gt;
HEALTH_ASSESS&lt;BR /&gt;
;&lt;BR /&gt;
RUN;&lt;BR /&gt;
PROC SQL NOPRINT;&lt;BR /&gt;
SELECT MT &lt;BR /&gt;
	INTO :MACVAR_METRICS SEPARATED BY ','&lt;BR /&gt;
FROM METRICS&lt;BR /&gt;
;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
%PUT &amp;amp;MACVAR_METRICS;&lt;BR /&gt;
%MACRO _LOOP_TO_TRANSPOSE_DATASETS(values);&lt;BR /&gt;
 %let count=1;                                                     &lt;BR /&gt;
  %let value=%qscan(&amp;amp;values,&amp;amp;count,%str(,));                        &lt;BR /&gt;
  /* Loop through the total number of values */                     &lt;BR /&gt;
  %do %while(&amp;amp;value ne);                                            &lt;BR /&gt;
     %put &amp;amp;value;                                                 &lt;BR /&gt;
     %let count=%eval(&amp;amp;count+1);                                  &lt;BR /&gt;
     %let value=%qscan(&amp;amp;values,&amp;amp;count,%str(,));                  &lt;BR /&gt;
  %end;                                                           &lt;BR /&gt;
&lt;BR /&gt;
%MEND _LOOP_TO_TRANSPOSE_DATASETS;&lt;BR /&gt;
                                          &lt;BR /&gt;
/* %STR is used to mask the commas from the macro compiler when */    &lt;BR /&gt;
/* the macro %LOOP is called.                                   */    &lt;BR /&gt;
%_LOOP_TO_TRANSPOSE_DATASETS(&amp;amp;MACVAR_METRICS) &lt;BR /&gt;
&lt;BR /&gt;
I am getting this error -&lt;BR /&gt;
SYMBOLGEN:  Macro variable MACVAR_METRICS resolves to TOT_COMP_PGM,REG_MEM,BIO_SCREEN,FAX_MAIL_BIO_SCREEN,HEALTH_ASSESS&lt;BR /&gt;
ERROR: More positional parameters found than defined.&lt;BR /&gt;
&lt;BR /&gt;
I tried using different ways to invoke the macro but I  still keep getting an error -&lt;BR /&gt;
%_LOOP_TO_TRANSPOSE_DATASETS(value=&amp;amp;MACVAR_METRICS)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
46         TOT_COMP_PGM,REG_MEM,BIO_SCREEN,FAX_MAIL_BIO_SCREEN,HEALTH_ASSESS&lt;BR /&gt;
                                __________&lt;BR /&gt;
                                180&lt;BR /&gt;
ERROR: All positional parameters must precede keyword parameters.&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
I would appreciate any help.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert.</description>
      <pubDate>Tue, 29 Mar 2011 20:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40228#M8155</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-29T20:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40229#M8156</link>
      <description>Hello SASpert,&lt;BR /&gt;
&lt;BR /&gt;
I've replaced your macro call with this one and did not get any errors:&lt;BR /&gt;
&lt;BR /&gt;
%_LOOP_TO_TRANSPOSE_DATASETS(%Bquote(&amp;amp;MACVAR_METRICS)) &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 29 Mar 2011 20:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40229#M8156</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-29T20:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40230#M8157</link>
      <description>Hello SPR,&lt;BR /&gt;
Thank you for your suggestion. The macro runs fine but I get back this in the log -&lt;BR /&gt;
&lt;BR /&gt;
SYMBOLGEN:  Macro variable COUNT resolves to 1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VALUE resolves to %bqoute(TOT_COMP_PGM&lt;BR /&gt;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;
SYMBOLGEN:  Macro variable VALUE resolves to %bqoute(TOT_COMP_PGM&lt;BR /&gt;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;
%bqoute(TOT_COMP_PGM&lt;BR /&gt;
&lt;BR /&gt;
I think the string '%Bquote' too is being passed to the macro while invocation. I want only the TOT_COMP_PGM to return for the first value.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert</description>
      <pubDate>Tue, 29 Mar 2011 21:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40230#M8157</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-29T21:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40231#M8158</link>
      <description>Another better choice is :&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%Macro_Loop /parmbuff;&lt;BR /&gt;
........&amp;amp;syspbuff............&lt;BR /&gt;
%mend;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 30 Mar 2011 05:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40231#M8158</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-30T05:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40232#M8159</link>
      <description>Hello SASpert, &lt;BR /&gt;
&lt;BR /&gt;
I did not see %bqoute(TOT_COMP_PGM in my LOG I see TOT_COMP_PGM. I use EG 4.3 may be this is the reason? What version of SAS or EG do you use?&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 30 Mar 2011 13:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40232#M8159</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-30T13:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40233#M8160</link>
      <description>Hi SPR,&lt;BR /&gt;
I have SAS Enterprise Guide 4.1 (4.1.0.1016). Do you know if different versions of EG can cause such issues? I was thinking the macro quoting functions are pretty much standard, arent they?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
saspert.</description>
      <pubDate>Wed, 30 Mar 2011 15:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40233#M8160</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-30T15:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40234#M8161</link>
      <description>Hi Ksharp,&lt;BR /&gt;
Thank you for your suggestion. This option is new to me. I just looked up the documentation for 9.1.3 and it might be worth a try.&lt;BR /&gt;
&lt;BR /&gt;
But do you know if it will work for 2 macro variables which will have several values like this &lt;BR /&gt;
&lt;BR /&gt;
%macro somemacro  (value1=,value2=);&lt;BR /&gt;
%mend;&lt;BR /&gt;
%somemacro (a1,b1,c1, b2,c2,d2)&lt;BR /&gt;
&lt;BR /&gt;
The SAS example has only 1 macro variable. &lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
saspert.</description>
      <pubDate>Wed, 30 Mar 2011 15:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40234#M8161</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2011-03-30T15:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40235#M8162</link>
      <description>Hello SASpert,&lt;BR /&gt;
&lt;BR /&gt;
I do not know the answers on your questions because do not have EG 4.1. I suggest using " " instead of "," as a separator:&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC SQL NOPRINT;&lt;BR /&gt;
  SELECT MT &lt;BR /&gt;
  INTO :MACVAR_METRICS SEPARATED BY ' '&lt;BR /&gt;
FROM METRICS&lt;BR /&gt;
;&lt;BR /&gt;
QUIT;&lt;BR /&gt;
%PUT &amp;amp;MACVAR_METRICS;&lt;BR /&gt;
%MACRO _LOOP_TO_TRANSPOSE_DATASETS(values);&lt;BR /&gt;
  %let count=1; &lt;BR /&gt;
  %let value=%qscan(&amp;amp;values,&amp;amp;count,%str(" ")); &lt;BR /&gt;
  /* Loop through the total number of values */ &lt;BR /&gt;
  %do %while(&amp;amp;value ne); &lt;BR /&gt;
    %put &amp;amp;value; &lt;BR /&gt;
    %let count=%eval(&amp;amp;count+1); &lt;BR /&gt;
    %let value=%qscan(&amp;amp;values,&amp;amp;count,%str(" ")); &lt;BR /&gt;
  %end; &lt;BR /&gt;
%MEND _LOOP_TO_TRANSPOSE_DATASETS;&lt;BR /&gt;
&lt;BR /&gt;
/* %STR is used to mask the commas from the macro compiler when */ &lt;BR /&gt;
/* the macro %LOOP is called. */ &lt;BR /&gt;
%_LOOP_TO_TRANSPOSE_DATASETS(&amp;amp;MACVAR_METRICS) &lt;BR /&gt;
[/pre]&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 30 Mar 2011 16:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40235#M8162</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-30T16:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40236#M8163</link>
      <description>Part of the issue may be use of %QSCAN which quotes special characters, ie %bquote.&lt;BR /&gt;
&lt;BR /&gt;
%scan may yield more expected results BUT you want to pass a list with commas either with %STR() , another approach that makes the commas invisible (or not used) or the PARMBUFF automatic macro variable</description>
      <pubDate>Wed, 30 Mar 2011 21:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40236#M8163</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-03-30T21:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Loop issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40237#M8164</link>
      <description>Yes. This way  only supports  1 macro variable.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 01 Apr 2011 10:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Loop-issue/m-p/40237#M8164</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-01T10:35:03Z</dc:date>
    </item>
  </channel>
</rss>

