<?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: Call macro from macro using variable value as parm in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459211#M29587</link>
    <description>&lt;P&gt;If your having parameters that long then consider re-working your process.&amp;nbsp; There is never a need to use macros, just change the way of thinking about things.&amp;nbsp; One of the main things we see pop up here is people passing in lists of items.&amp;nbsp; Take this example, you need to filter off a list of items, you could put those items in a macro parameter like:&lt;/P&gt;
&lt;PRE&gt;%macro filter (list=);
  proc sql;
    select * from have where myvar in (&amp;amp;list.);
  quit;
%mend filter;&lt;/PRE&gt;
&lt;P&gt;Now if your list grows this type of thing can get unwieldy and hard to program with.&amp;nbsp; Use the power of datasets makes this far simpler, just with a simple change of thinking:&lt;/P&gt;
&lt;PRE&gt;%macro filter (listds=);
  proc sql;
    select * from have where myvar in (select var from &amp;amp;listds.);
  quit;
%mend filter;&lt;/PRE&gt;
&lt;P&gt;In this instance we have a dataset with our values, and pass that into the macro, the dataset can be any size and be used just like any other dataset.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regards to the "&lt;SPAN&gt;longer than 262 characters, it seems CALL EXECUTE fails in this case?" - what do you mean fails?&amp;nbsp; What happens, what is in the log etc.&amp;nbsp; Do you mean you get a warning about length, if so there is: options noquotelenmax; which will turn off that warning, make sure to turn it back on afterwards.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 02 May 2018 08:13:31 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-05-02T08:13:31Z</dc:date>
    <item>
      <title>Call macro from macro using variable value as parm</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459186#M29582</link>
      <description>&lt;P&gt;Hope someone can help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to call a macro from within another macro but only every time 'category' changes, and then pass the initiate macro the value of a variable sorted_profile_table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have spent hours on this and all the help online isn't helping, thank you for your assistance!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code (pseudocode in some cases):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%macro load_control_tables;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;proc sort data=profile_table out=sorted_profile_table;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;by category;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;set sorted_profile_table ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;by category;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;if first.category then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;do;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call another macro (called %initiate) using the VALUE of a VARIABLE from sorted_profile_table&amp;nbsp;(as a macro variable)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%mend;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The macro @initiate is within another program and has been run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks folks!&lt;BR /&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 05:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459186#M29582</guid>
      <dc:creator>markc</dc:creator>
      <dc:date>2018-05-02T05:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Call macro from macro using variable value as parm</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459187#M29583</link>
      <description>&lt;P&gt;You need Call execute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer to the technical paper by the genius none other than Ian whitlock&lt;/P&gt;&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF" target="_blank"&gt;http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 05:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459187#M29583</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-02T05:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Call macro from macro using variable value as parm</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459191#M29584</link>
      <description>Thank you very much novinosrin, worked! Good on you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 02 May 2018 05:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459191#M29584</guid>
      <dc:creator>markc</dc:creator>
      <dc:date>2018-05-02T05:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Call macro from macro using variable value as parm</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459192#M29585</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subsequent to this, what if the parameters to a macro call are longer than 262 characters, it seems CALL EXECUTE fails in this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 06:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459192#M29585</guid>
      <dc:creator>markc</dc:creator>
      <dc:date>2018-05-02T06:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Call macro from macro using variable value as parm</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459211#M29587</link>
      <description>&lt;P&gt;If your having parameters that long then consider re-working your process.&amp;nbsp; There is never a need to use macros, just change the way of thinking about things.&amp;nbsp; One of the main things we see pop up here is people passing in lists of items.&amp;nbsp; Take this example, you need to filter off a list of items, you could put those items in a macro parameter like:&lt;/P&gt;
&lt;PRE&gt;%macro filter (list=);
  proc sql;
    select * from have where myvar in (&amp;amp;list.);
  quit;
%mend filter;&lt;/PRE&gt;
&lt;P&gt;Now if your list grows this type of thing can get unwieldy and hard to program with.&amp;nbsp; Use the power of datasets makes this far simpler, just with a simple change of thinking:&lt;/P&gt;
&lt;PRE&gt;%macro filter (listds=);
  proc sql;
    select * from have where myvar in (select var from &amp;amp;listds.);
  quit;
%mend filter;&lt;/PRE&gt;
&lt;P&gt;In this instance we have a dataset with our values, and pass that into the macro, the dataset can be any size and be used just like any other dataset.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regards to the "&lt;SPAN&gt;longer than 262 characters, it seems CALL EXECUTE fails in this case?" - what do you mean fails?&amp;nbsp; What happens, what is in the log etc.&amp;nbsp; Do you mean you get a warning about length, if so there is: options noquotelenmax; which will turn off that warning, make sure to turn it back on afterwards.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 08:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Call-macro-from-macro-using-variable-value-as-parm/m-p/459211#M29587</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-02T08:13:31Z</dc:date>
    </item>
  </channel>
</rss>

