<?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 Code with two variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538906#M6996</link>
    <description>&lt;P&gt;Thank you for your help, both solutions from RW9 and PaigeMiller working.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Feb 2019 09:18:33 GMT</pubDate>
    <dc:creator>rimob</dc:creator>
    <dc:date>2019-02-27T09:18:33Z</dc:date>
    <item>
      <title>Macro Code with two variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538634#M6978</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to run a macro with 2 variables, first one with period from 201801 to 201901 and the second with a table name:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro do_list;&lt;BR /&gt;%do I=201801 %to 201812;&lt;BR /&gt;%do j in ("Mag1","Mag2","Mag2");&lt;BR /&gt;%import(luna=&amp;amp;I.,vendor=&amp;amp;J.);&lt;BR /&gt;%put &amp;amp;I. &amp;amp;J.;&lt;BR /&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%import(luna=201901,Vendor=Mag1);&lt;BR /&gt;%import(luna=201901,Vendor=Mag2);&lt;BR /&gt;%import(luna=201901,Vendor=Mag3);&lt;BR /&gt;%mend;&lt;BR /&gt;%do_list;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm trying this but i have the following error :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: An unexpected semicolon occurred in the %DO statement. A dummy macro will be compiled.&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&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;&lt;P&gt;could you help with a solution ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538634#M6978</guid>
      <dc:creator>rimob</dc:creator>
      <dc:date>2019-02-26T14:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Code with two variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538637#M6979</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do j in ("Mag1","Mag2","Mag2");&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is not valid syntax and will not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A simplified version of the j-loop portion code that does work (note that we don't normally use quotes around the values assigned to macro variables):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro oink;
    %let stuff=Mag1 Mag2 Mag3;
    %do j = 1 %to 3;
		%let thisname=%scan(&amp;amp;stuff,&amp;amp;j,%str( ));
		%put &amp;amp;=j &amp;amp;=thisname;
    %end;
%mend;

%oink&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also hint hint hint, when you have error messages from a SAS macro, use this command at the start of the program to try to debug&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen mlogic;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 14:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538637#M6979</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-26T14:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Code with two variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538646#M6980</link>
      <description>&lt;P&gt;You can simplify things by using Base SAS (as always):&lt;/P&gt;
&lt;PRE&gt;data _null_;
  do i=201801 to 201812;
    do j="Mag1","Mag2","Mag3";
      call execute(cats('%import(luna=',put(i,best.),',vendor=',j,');'));
    end;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 15:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538646#M6980</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-26T15:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Code with two variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538906#M6996</link>
      <description>&lt;P&gt;Thank you for your help, both solutions from RW9 and PaigeMiller working.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 09:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-Code-with-two-variables/m-p/538906#M6996</guid>
      <dc:creator>rimob</dc:creator>
      <dc:date>2019-02-27T09:18:33Z</dc:date>
    </item>
  </channel>
</rss>

