<?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: Improve codes  - macro in a macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594014#M34808</link>
    <description>&lt;P&gt;Why are you trying to make this so complicated?&lt;/P&gt;
&lt;P&gt;You could pass in the NAME of the macro you want to call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro addinfoto_ds
(ds_in
,var
,ds_out
,submacro_name
);
  %_eg_conditional_dropds(&amp;amp;ds_out);
  %varexist(&amp;amp;ds_in, &amp;amp;var);
  %if "&amp;amp;result"="0" %then %do;
    %&amp;amp;submacro_name (&amp;amp;ds_in, &amp;amp;ds_out);
  %end;
%mend addinfoto_ds;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Oct 2019 02:39:01 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-10-04T02:39:01Z</dc:date>
    <item>
      <title>Improve codes  - macro in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594011#M34806</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can anyone provide suggestions to improve below codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently below codes works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; AddInfoTo_DS (DS_in, Var, DS_out);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;_eg_conditional_dropds&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;DS_out);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; result = ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* if &amp;amp;Var exist then do nothing, else run the relevant programme to add &amp;amp;Var */&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;VarExist&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;DS_in, &amp;amp;Var);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%if&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;result"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"0"&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Add_ID_ByName&lt;/I&gt;&lt;/STRONG&gt; (&amp;amp;DS_in, &amp;amp;DS_out);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;AddInfoTo_DS &lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;InputData, ID, Step2_Dump);&lt;/FONT&gt;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Ideally, I would like to include macro "%&lt;STRONG&gt;&lt;I&gt;Add_ID_ByName&lt;/I&gt;&lt;/STRONG&gt; (&amp;amp;DS_in, &amp;amp;DS_out);"&amp;nbsp; as part of the &lt;/FONT&gt;parameters to run macro "&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;AddInfoTo_DS &lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;InputData, ID, Step2_Dump);&lt;/FONT&gt;"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e. when a particular information is missing, then run the relevant programme to add that piece of info to the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any chance to get that done?&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;Sue&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594011#M34806</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2019-10-04T02:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Improve codes  - macro in a cacro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594013#M34807</link>
      <description>Add another %IF/%THEN branch?</description>
      <pubDate>Fri, 04 Oct 2019 02:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594013#M34807</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-04T02:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Improve codes  - macro in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594014#M34808</link>
      <description>&lt;P&gt;Why are you trying to make this so complicated?&lt;/P&gt;
&lt;P&gt;You could pass in the NAME of the macro you want to call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro addinfoto_ds
(ds_in
,var
,ds_out
,submacro_name
);
  %_eg_conditional_dropds(&amp;amp;ds_out);
  %varexist(&amp;amp;ds_in, &amp;amp;var);
  %if "&amp;amp;result"="0" %then %do;
    %&amp;amp;submacro_name (&amp;amp;ds_in, &amp;amp;ds_out);
  %end;
%mend addinfoto_ds;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594014#M34808</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-04T02:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Improve codes  - macro in a cacro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594016#M34809</link>
      <description>&lt;P&gt;Hey Reeza, Thanks for your suggestions,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am testing below codes and hope it will eventually works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; AddInfoTo_DS (DS_in, Var, DS_out);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;_eg_conditional_dropds&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;DS_out);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; result = ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;VarExist&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;DS_in, &amp;amp;Var);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%if&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;result"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"0"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ResultBefore="&amp;amp;result";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Add_&lt;/I&gt;&lt;/STRONG&gt;&amp;amp;Var (&amp;amp;DS_in, &amp;amp;DS_out);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ResultAfter="&amp;amp;result";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;AddInfoTo_DS&lt;/I&gt;&lt;/STRONG&gt; (&amp;amp;InputData, ID, Step2_Dump);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;AddInfoTo_DS&lt;/I&gt;&lt;/STRONG&gt; (Step2_Dump, Day, Step2_Dump);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594016#M34809</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2019-10-04T02:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Improve codes  - macro in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594018#M34810</link>
      <description>&lt;P&gt;Hi Tom! Exactly! I had the same idea, and it works!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for being there and providing ideas !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 02:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594018#M34810</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2019-10-04T02:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Improve codes  - macro in a macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594056#M34811</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293494"&gt;@Suzy_Cat&lt;/a&gt;&amp;nbsp;, well done on supplying your code and thinking along the same lines as the given answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any of the replies has given you the answer you wanted then please mark it as the solution (not this post) as it can help others to easily find a solution to a similar problem and it is an additional acknowledgement of the time and effort taken by the person who has posted the answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 09:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Improve-codes-macro-in-a-macro/m-p/594056#M34811</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-10-04T09:19:07Z</dc:date>
    </item>
  </channel>
</rss>

