<?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: Deleting local macro variable within a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/458785#M116452</link>
    <description>&lt;P&gt;What about simply saying;&lt;/P&gt;&lt;P&gt;%let mvar=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Apr 2018 18:35:35 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2018-04-30T18:35:35Z</dc:date>
    <item>
      <title>Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64493#M14014</link>
      <description>If I want to delete local macro variable within a macro, what is the process? &lt;BR /&gt;
Can any one explain me with an example.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Sidhu</description>
      <pubDate>Thu, 13 Aug 2009 17:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64493#M14014</guid>
      <dc:creator>Siddhartha</dc:creator>
      <dc:date>2009-08-13T17:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64494#M14015</link>
      <description>I'm not aware that you can delete a LOCAL macro variable.  You can delete a global variable with %SYMDEL.  Of course, you can always set the local variable to a null value, but you didn't say what your purpose is, so I don't know whether that would help or not.</description>
      <pubDate>Thu, 13 Aug 2009 17:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64494#M14015</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-13T17:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64495#M14016</link>
      <description>Alas, but you can't.  %SYMDEL only works on global macro variables.  If you need to create then delete a macro variable from within a macro, make it global by using the %GLOBAL statement, then you can delete it when done.</description>
      <pubDate>Fri, 14 Aug 2009 17:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64495#M14016</guid>
      <dc:creator>PatrickG</dc:creator>
      <dc:date>2009-08-14T17:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64496#M14017</link>
      <description>why would you need to delete the local macro variable?&lt;BR /&gt;
Make the macro siimpler and lose the local mvars as it closes.&lt;BR /&gt;
There are many ways to eliminate such a problem.&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
PeterC</description>
      <pubDate>Mon, 17 Aug 2009 16:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64496#M14017</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-08-17T16:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64497#M14018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;****************Update on 7/2/2015 I was informed by tech support that this works in SAS version 9.3 as a result of a glitch - it does not work in SAS 9.4****************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know this is an old thread but I found it unanswered and then figured out a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _localvaltest ();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*setting up a local macro variable and putting it into a dataset*/&lt;/P&gt;&lt;P&gt;%let localvar=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.shoes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local=&amp;amp;localvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*creating a set that contains currently defined macro variables*/&lt;/P&gt;&lt;P&gt;data vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vmacro;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*write local vars to the log*/&lt;/P&gt;&lt;P&gt;%put&amp;nbsp; _local_;&lt;/P&gt;&lt;P&gt;%put localvar value is &amp;amp;localvar;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*executing a null step that deletes local variables from the macro table*/&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set vars;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if scope='_LOCALVALTEST' then call execute ('%symdel '||trim(left(name))||';');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*write local vars to the log after the delete - does not show any and comes back unresolved for second&amp;nbsp; put*/&lt;BR /&gt;%put&amp;nbsp; _local_;&lt;/P&gt;&lt;P&gt;%put localvar value is &amp;amp;localvar;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*creating a new set that shows the local macro variable has been deleted by the previous step*/&lt;/P&gt;&lt;P&gt;data vars2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vmacro;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%_localvaltest;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Scott Moore; Updated to correct syntax error and add %put statemets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 15:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64497#M14018</guid>
      <dc:creator>Scott_C_Moore</dc:creator>
      <dc:date>2013-08-20T15:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64498#M14019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Scott,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think that's a solution.&amp;nbsp; I'm getting all kinds of errors, starting with the first comment which is missing a / at the end.&amp;nbsp; So as posted everything except the last data step is commented out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be quite surprising if you could trick %SYMDEL into deleting a local variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you play with this more and it still looks like you have deleted a local macro variable, I woud suggest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. ) add %put _local_ ;&amp;nbsp; before and after your deletion, to show the change&lt;/P&gt;&lt;P&gt;2. ) turn on options MPRINT and run the code in batch (so you know you have a clean session)&lt;/P&gt;&lt;P&gt;3. ) post the log from that session (showing both the macro definition and the execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 17:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64498#M14019</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-08-20T17:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64499#M14020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Couldn't figure out how to cut and paste from my SAS editor and ended up typing the reply, which is never a good idea. Fixed the problem and tested it's working properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 17:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64499#M14020</guid>
      <dc:creator>Scott_C_Moore</dc:creator>
      <dc:date>2013-08-20T17:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64500#M14021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have SAS/EG use Copy HTML Source to Clipboard then click HTML in "this" editor and past.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 18:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64500#M14021</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-08-20T18:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64501#M14022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do another test and make a global version of the local macro variable you are trying to delete.&amp;nbsp; Which one gets deleted?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 18:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64501#M14022</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-08-20T18:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64502#M14023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I create a global version of the same variable, the scope in the sashelp.vmacro is global and it no longer meets the condition of if scope= '_LOCALVALTEST' so it does not get deleted. I'll edit the program one more time to %put the value of the macro variable and it will come back as unresolved for the second %put statement showing that the value has been deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My EG install is broken and getting IT to reinstall is such a hassle that I just use the enhanced editor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 18:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/64502#M14023</guid>
      <dc:creator>Scott_C_Moore</dc:creator>
      <dc:date>2013-08-20T18:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/257055#M49312</link>
      <description>let me know if this work, thnx&lt;BR /&gt;&lt;BR /&gt;*create variable;&lt;BR /&gt;%let var = 1;&lt;BR /&gt;&lt;BR /&gt;*display;&lt;BR /&gt;%put varibale var has been create and the value is &amp;amp;var;&lt;BR /&gt;&lt;BR /&gt;*further proof;&lt;BR /&gt;data view_var_b4;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set sashelp.vmacro;&lt;BR /&gt;run;&lt;BR /&gt;*create macro;&lt;BR /&gt;%macro del_var (del=);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%symdel &amp;amp;del;&lt;BR /&gt;%mend del_var;&lt;BR /&gt;&lt;BR /&gt;*run macro;&amp;nbsp;&lt;BR /&gt;%del_var (del=var);&lt;BR /&gt;&lt;BR /&gt;*check variable table&amp;nbsp;&lt;BR /&gt;data view_var_after;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set sashelp.vmacro;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;*further proof;&amp;nbsp;&lt;BR /&gt;%put _user_;&amp;nbsp;</description>
      <pubDate>Wed, 16 Mar 2016 15:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/257055#M49312</guid>
      <dc:creator>DennisWilliams</dc:creator>
      <dc:date>2016-03-16T15:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting local macro variable within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/458785#M116452</link>
      <description>&lt;P&gt;What about simply saying;&lt;/P&gt;&lt;P&gt;%let mvar=;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 18:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-local-macro-variable-within-a-macro/m-p/458785#M116452</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2018-04-30T18:35:35Z</dc:date>
    </item>
  </channel>
</rss>

