<?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: %symdel _all_ except in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554982#M9592</link>
    <description>Sorry, you're right. I was confusing "%put _all_" with %symdel. There is no %symdel _all_.</description>
    <pubDate>Tue, 30 Apr 2019 11:47:22 GMT</pubDate>
    <dc:creator>LFern</dc:creator>
    <dc:date>2019-04-30T11:47:22Z</dc:date>
    <item>
      <title>%symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554311#M9482</link>
      <description>&lt;P&gt;Suppose I have 3 %let variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var1 = 1;&lt;/P&gt;&lt;P&gt;%let var2 = 2;&lt;/P&gt;&lt;P&gt;%let var3 = 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know %symdel _all_ will erase all three. How do I add an exception to the "all"? I want to be able to delete all except var3, for example.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 15:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554311#M9482</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-26T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554360#M9485</link>
      <description>Loop though them, deleting one at a time but skip var3.</description>
      <pubDate>Fri, 26 Apr 2019 17:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554360#M9485</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-04-26T17:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554386#M9494</link>
      <description>&lt;P&gt;Make your own list of symbols (macro variables) to delete from the list of existing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var1=x;
%let var2=y;
%let var3=z;
proc sql noprint;
select distinct name into :symlist separated by ' '
from dictionary.macros
where scope='GLOBAL'
  and name like 'VAR%'
  and not name='VAR3'
;
%put &amp;amp;=var1 &amp;amp;=var2 &amp;amp;=var3;
%symdel &amp;amp;symlist;
%put &amp;amp;=var1 &amp;amp;=var2 &amp;amp;=var3;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2019 20:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554386#M9494</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-26T20:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554388#M9495</link>
      <description>&lt;P&gt;I must have missed something along the way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since when does %SYMDEL accept lists of macro variables such as _ALL_ ?&amp;nbsp; Last I checked, you had to spell out the names of all macro variables that you want deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, this can be accomplished, writing a macro such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%delete_most (except=var3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the way you go about it depends on how %SYMDEL _ALL_ behaves.&amp;nbsp; Have you tried that statement, and what were the results?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 20:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554388#M9495</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-26T20:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554407#M9502</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262848"&gt;@LFern&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Suppose I have 3 %let variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let var1 = 1;&lt;/P&gt;
&lt;P&gt;%let var2 = 2;&lt;/P&gt;
&lt;P&gt;%let var3 = 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know %symdel _all_ will erase all three. How do I add an exception to the "all"? I want to be able to delete all except var3, for example.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;74   %symdel _all_;
WARNING: Attempt to delete macro variable _ALL_ failed. Variable not found.


&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;is correct as far as SAS 9.4 TS Level 1M4 goes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that actually works for you to remove multiple macro variables&amp;nbsp;then please describe the environment you are using.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 21:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554407#M9502</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-26T21:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554545#M9524</link>
      <description>&lt;P&gt;Heres the macro i use to clean up macro vars.&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can change it to suit it to your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro Clean_Up_Macro_Vars(prefix);

	/*****************************************************************/ 
	/*         Delete macro variables created by previous Run        */ 
	/*****************************************************************/ 

	    %nrstr(options nosource nomprint nonotes;);
        /* Create list of macro variables to be deleted */
		proc sort data=sashelp.vmacro  nodupkey out=Temp_dsn;				
			by name;
			where name =: upcase("&amp;amp;prefix."); 
		run;

		
		data _null_;
			set Temp_dsn;
			/* Execute %SymDel against each Macro variable */
			if scope='GLOBAL' then 
			call execute('%symdel ' ||trim(left(name))||';');		
		run; 

		proc delete data=Temp_dsn;run;
		%nrstr(options source mprint notes;);
%Mend; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Apr 2019 01:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554545#M9524</guid>
      <dc:creator>smijoss1</dc:creator>
      <dc:date>2019-04-28T01:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554562#M9530</link>
      <description>There are definitely some useful features here.  &lt;BR /&gt;&lt;BR /&gt;Rather than specifying a prefix, this application needs to specify a list of macro variables to skip over.</description>
      <pubDate>Sun, 28 Apr 2019 08:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554562#M9530</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-28T08:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554586#M9533</link>
      <description>All my temp macro vars are prefixed with 1 or 2 underscore. So it suits my needs.. bht feel free to modify to your needs</description>
      <pubDate>Sun, 28 Apr 2019 14:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554586#M9533</guid>
      <dc:creator>smijoss1</dc:creator>
      <dc:date>2019-04-28T14:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554631#M9537</link>
      <description>&lt;P&gt;OK, here goes.&amp;nbsp; It is expected that the macro will be called along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%delete_most (except=var3 var5)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro delete_most (except=);

   %local k;

   proc sort data=sashelp.vmacro nodupkey out=delete_these;
      by name;
      where scope='GLOBAL' and upcase(name) not in
         ( %do k = 1 %to %sysfunc(countw(&amp;amp;except) ) ;
               "%upcase(%scan(&amp;amp;except, &amp;amp;k))"
         );
   run;

   data _null_;
      call execute ('%symdel ');
      do until (done);
         set delete_these end=done;
         call execute(name);
      end;
      call execute (';') ;
   run; 

%mend delete_most; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;It's untested code, and so might need a slight tweak.&amp;nbsp; But it should be about right.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Apr 2019 23:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554631#M9537</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-28T23:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554838#M9576</link>
      <description>&lt;P&gt;Hi there, thank you so much for the feedback! The delete_these dataset captures exactly what I want (to identify everything except&amp;nbsp;var=3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, something is going wrong in the call execute function (see attached log). I tried to troubleshoot error 180-322 but wasn't able to find a fix for this specific situation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554838#M9576</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-29T19:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554843#M9577</link>
      <description>&lt;P&gt;For starters, let's try inserting a STOP statement in the DATA _NULL_ step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data _null_;
      call execute ('%symdel ');
      do until (done);
         set delete_these end=done;
         call execute(name);
      end;
      call execute (';') ;
      STOP;
   run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's definitely needed, so let's see if that takes care of all the problems.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 20:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554843#M9577</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-29T20:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554848#M9579</link>
      <description>&lt;P&gt;Note sure why you need to worry about deleting macro variables (symbols).&amp;nbsp; They aren't doing anybody any harm.&lt;/P&gt;
&lt;P&gt;But your macro can be a lot simpler and more flexible.&lt;/P&gt;
&lt;P&gt;Here is version that allows listing names to include, exclude or a prefix.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro delete_most(include,exclude,prefix);
%local list;
proc sql noprint;
  select name into :list separated by ' '
  from dictionary.macros
  where offset=0 and scope='GLOBAL'
%if %length(&amp;amp;prefix) %then 
    and name like %upcase(%bquote('&amp;amp;prefix%'))
;
%if %length(&amp;amp;include) %then 
    and findw("&amp;amp;include",name,' ','sit')
;
%if %length(&amp;amp;exclude) %then
    and not findw("&amp;amp;exclude",name,' ','sit')
;
  ;
quit;
%if &amp;amp;sqlobs %then %do;
  %symdel &amp;amp;list;
%end;
%mend delete_most; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 20:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554848#M9579</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T20:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554982#M9592</link>
      <description>Sorry, you're right. I was confusing "%put _all_" with %symdel. There is no %symdel _all_.</description>
      <pubDate>Tue, 30 Apr 2019 11:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554982#M9592</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-30T11:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554987#M9593</link>
      <description>&lt;P&gt;Even with the stop, I'm getting the same 180-322 error as before:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: CALL EXECUTE generated line.&lt;/P&gt;&lt;P&gt;2 + VAR1&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;/P&gt;&lt;P&gt;2 + VAR1&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 12:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/554987#M9593</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-30T12:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555018#M9595</link>
      <description>&lt;P&gt;I think I got something to work! I took the first part of your macro (where you create "delete_these") but used a different execute function that I found online:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;----------------------------&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; VAR1 = 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; VAR2 = 2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; VAR3 = 3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; delvars(except=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=sashelp.vmacro nodupkey out=delete_these;&lt;/P&gt;&lt;P&gt;by name;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;where scope=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'GLOBAL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; and upcase(name) not in&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;( &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; k = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(countw(&amp;amp;except) ) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"%upcase(%scan(&amp;amp;except, &amp;amp;k))"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set delete_these;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if scope=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"GLOBAL"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; then call execute (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%symdel '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; || trim(left(name))||&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;';'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; %&lt;STRONG&gt;&lt;I&gt;delvars&lt;/I&gt;&lt;/STRONG&gt;(except=var3);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked for me as far as I can tell. %put _global_ now only returns var3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you see anything obviously problematic?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 13:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555018#M9595</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-30T13:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555025#M9596</link>
      <description>&lt;P&gt;SAS did not like getting the %SYMDEL statement sent to it by CALL EXECUTE in multiple pieces.&amp;nbsp; The first %SYMDEL code was interpreted by the macro processor and put nothing onto the stack of commands to run after the data step.&lt;/P&gt;
&lt;P&gt;So it ended up thinking you are trying to run a command like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;VAR1 VAR2 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By sending a complete %SYMDEL statement in each CALL EXECUTE string you avoid that problem.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(catx(' ','%symdel',name,';'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also have fixed this by wrapping the original %SYMDEL code inside of %NRSTR() so that the %SYMDEL statement would be pushed onto the stack to execute after the data step.&lt;/P&gt;
&lt;PRE&gt;1780  %put &amp;amp;=var1 &amp;amp;=var2 &amp;amp;=var3; ;
VAR1=x VAR2=x VAR3=x
1781  data _null_;
1782    if _n_=1 then call execute('%nrstr(%symdel) ');
1783    if eof then call execute(';');
1784    set test end=eof;
1785    call execute(name);
1786  run;

NOTE: There were 3 observations read from the data set WORK.TEST.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1    + %symdel
2    + var1
3    + var2
4    + var3
5    + ;
1787  %put &amp;amp;=var1 &amp;amp;=var2 &amp;amp;=var3; ;
WARNING: Apparent symbolic reference VAR1 not resolved.
WARNING: Apparent symbolic reference VAR2 not resolved.
WARNING: Apparent symbolic reference VAR3 not resolved.
var1 var2 var3
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2019 13:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555025#M9596</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T13:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555179#M9612</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really like this code!&lt;/P&gt;&lt;P&gt;I wasn't sure how to work with %put functions (i.e., I have no idea what it does)&amp;nbsp;so I modified your code slightly and got this error:&lt;/P&gt;&lt;P&gt;-------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; var1=1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; var2=2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; var3=3;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; :symlist separated &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dictionary.macros&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; scope=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'GLOBAL'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; not name=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'var3'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;quit&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%symdel&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;symlist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Attempt to delete automatic macro variable SYS_SQL_IP_ALL.&lt;/P&gt;&lt;P&gt;ERROR: Attempt to delete automatic macro variable SYS_SQL_IP_STMT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm guessing that the "sys_sql" are automatically created during the sql procedure. I suppose I could work around this error&amp;nbsp;by including 2 more "and not name=" lines that capture both "sys_sql" macro variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a downside of using "from sashelp.vmacro" instead of "from &lt;FONT face="Courier New" size="2"&gt;dictionary.macros&lt;/FONT&gt;"?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 19:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555179#M9612</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-30T19:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555187#M9616</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262848"&gt;@LFern&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Attempt to delete automatic macro variable SYS_SQL_IP_ALL.&lt;/P&gt;
&lt;P&gt;ERROR: Attempt to delete automatic macro variable SYS_SQL_IP_STMT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS has a lot that right hand not knowing what the left hand is doing type of problems.&amp;nbsp; If there were AUOTMATIC macro variables they should have been made with SCOPE='AUTOMATIC' instead of SCOPE='GLOBAL'.&lt;/P&gt;
&lt;P&gt;Yes if you really made a macro you used a lot you might want to make sure not to attempt to delete those two macro variables.&lt;/P&gt;
&lt;P&gt;You might want expand the exclusion list to not try to eliminate any macro variables that start with SYS.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 19:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555187#M9616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T19:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555188#M9617</link>
      <description>quick follow up, so there's no downside of using "from sashelp.vmacro" instead of "from dictionary.macros"?</description>
      <pubDate>Tue, 30 Apr 2019 19:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555188#M9617</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-30T19:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: %symdel _all_ except</title>
      <link>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555189#M9618</link>
      <description>SASHELP.VMACRO is just a view to DICTIONARY.MACROS.&lt;BR /&gt;Unlike some other DICTIONARY tables there is no downside to using the SASHELP view since there are no performance issues with SASHELP.VMACRO.&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Apr 2019 19:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/symdel-all-except/m-p/555189#M9618</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-30T19:39:17Z</dc:date>
    </item>
  </channel>
</rss>

