<?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 a macro program referred by a macro variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139425#M261433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have brackets around the &amp;amp;dsn., the below works (I note you also miss the ampersand on the exists function):&lt;/P&gt;&lt;P&gt;%macro abc;&lt;BR /&gt;&amp;nbsp; %put hello;&lt;BR /&gt;%mend abc;&lt;/P&gt;&lt;P&gt;%macro action (dsn);&lt;BR /&gt;&amp;nbsp; %&amp;amp;dsn.;&lt;BR /&gt;%mend action;&lt;/P&gt;&lt;P&gt;%action(abc);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I would suggest there are better ways of doing something like this than having a macro per dataset, even creating one macro which accepts the dataset as a parameter:&lt;/P&gt;&lt;P&gt;%macro do_something (dset=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do_something(dset=abc);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or alternatively create a loop dataset and then use that to generate code with call execute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2014 13:08:19 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-03-11T13:08:19Z</dc:date>
    <item>
      <title>Call a macro program referred by a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139424#M261432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a number of macro programs that take different data sets for processing.&lt;/P&gt;&lt;P&gt; For example,&lt;/P&gt;&lt;P&gt;%macro Abc; /* Takes data set abc*/&lt;/P&gt;&lt;P&gt;..............&lt;/P&gt;&lt;P&gt;.............&lt;/P&gt;&lt;P&gt;%Mend Abc;&lt;/P&gt;&lt;P&gt;This way I have created a number of macro programs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to execute macro program 'Abc' if data set Abc exists,&lt;/P&gt;&lt;P&gt;%Macro&amp;nbsp; Action(Dsn);&lt;/P&gt;&lt;P&gt;%IF&amp;nbsp; %SYSFUNC(EXIST(Dsn))&amp;gt;0&amp;nbsp; %THEN %DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %(&amp;amp;Dsn);&amp;nbsp; /*Here is the problem*/&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%ELSE %DO;&lt;/P&gt;&lt;P&gt;%PUT***********Dataset &amp;amp;Dsn does not exist;&lt;/P&gt;&lt;P&gt;%END;&lt;/P&gt;&lt;P&gt;%MEND Action;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if I use&lt;/P&gt;&lt;P&gt;%Action(Abc);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The program fails to execute because&amp;nbsp; in %(&amp;amp;Dsn) , &amp;amp;Dsn fails to resolve so %Abc does not execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to fix this?&lt;/P&gt;&lt;P&gt;Thanks every one for your attention.&lt;/P&gt;&lt;P&gt;Raghu.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 12:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139424#M261432</guid>
      <dc:creator>rnmishra</dc:creator>
      <dc:date>2014-03-11T12:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Call a macro program referred by a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139425#M261433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have brackets around the &amp;amp;dsn., the below works (I note you also miss the ampersand on the exists function):&lt;/P&gt;&lt;P&gt;%macro abc;&lt;BR /&gt;&amp;nbsp; %put hello;&lt;BR /&gt;%mend abc;&lt;/P&gt;&lt;P&gt;%macro action (dsn);&lt;BR /&gt;&amp;nbsp; %&amp;amp;dsn.;&lt;BR /&gt;%mend action;&lt;/P&gt;&lt;P&gt;%action(abc);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I would suggest there are better ways of doing something like this than having a macro per dataset, even creating one macro which accepts the dataset as a parameter:&lt;/P&gt;&lt;P&gt;%macro do_something (dset=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do_something(dset=abc);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or alternatively create a loop dataset and then use that to generate code with call execute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 13:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139425#M261433</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-11T13:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Call a macro program referred by a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139426#M261434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This sounds like a bad design.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps explain more about what you're trying to do and someone can suggest better design techniques.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 14:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139426#M261434</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-11T14:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Call a macro program referred by a macro variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139427#M261435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is because the code the macro generated:&amp;nbsp; %(abc) is not valid syntax for a macro call.&amp;nbsp; You want it to generate %abc; or %abc() .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 16:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-macro-program-referred-by-a-macro-variable/m-p/139427#M261435</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-11T16:15:17Z</dc:date>
    </item>
  </channel>
</rss>

