<?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: Conditionally delete macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691046#M210286</link>
    <description>&lt;P&gt;Your idea seems pretty straight forward. However, if your question is to do with making a process efficient would lead to far reaching questions as to what and how you are trying to do? Why would you need those macro variables? And then why you want to delete those macro variables considering the fact macro variables are any deleted at the end of the session. It all depends on what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the standpoint of making a macro IN operator to work, the solution is just what was posted.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 18:39:30 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-10-12T18:39:30Z</dc:date>
    <item>
      <title>Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691022#M210273</link>
      <description>&lt;P&gt;I want to conditionally delete macro variable based on the value of other variable. In this case it is based on the value of the macro variable 'fnctl_cmpnt'. The macro variable 'FILE_TYPE' should be deleted as value of the macro variable 'fnctl_cmpnt'&amp;nbsp;is not in 'AD' or 'DQ'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/**macro variables**/
%let fnctl_cmpnt=GT;
%let FILE_TYPE=;

/*Delete macro variable conditionally*/
%macro del_mac_var;
data _null_;
%if &amp;amp;fnctl_cmpnt not in ('AD','DQ') %then %do;
%symdel FILE_TYPE;
%end;
run;
%mend;
%del_mac_var;

%put #### &amp;amp;FILE_TYPE.;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;27         %let fnctl_cmpnt=GT;
28         %let FILE_TYPE=;
29         
30         /*Delete macro variable conditionally*/
31         %macro del_mac_var;
32         data _null_;
33         %if &amp;amp;fnctl_cmpnt not in ('AD','DQ') %then %do;
34         %symdel FILE_TYPE;
35         %end;
36         run;
37         %mend;
38         %del_mac_var;
MLOGIC(DEL_MAC_VAR):  Beginning execution.
MPRINT(DEL_MAC_VAR):   data _null_;
SYMBOLGEN:  Macro variable FNCTL_CMPNT resolves to GT
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
       &amp;amp;fnctl_cmpnt not in ('AD','DQ') 
ERROR: The macro DEL_MAC_VAR will stop executing.
MLOGIC(DEL_MAC_VAR):  Ending execution.
39         
40         %put #### &amp;amp;FILE_TYPE.;
SYMBOLGEN:  Macro variable FILE_TYPE resolves to 
####&lt;/PRE&gt;
&lt;P&gt;Any leads to understand the cause for the issue?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 17:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691022#M210273</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-10-12T17:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691043#M210283</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options MINOPERATOR MINDELIMITER=',';
/**macro variables**/
%let fnctl_cmpnt=GT;
%let FILE_TYPE=;

/*Delete macro variable conditionally*/
%macro del_mac_var ;

%if not(&amp;amp;fnctl_cmpnt   in AD,DQ) %then %do;
%symdel FILE_TYPE;
%end;
%mend;
%del_mac_var
%put &amp;amp;=FILE_TYPE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LOG:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;254  options MINOPERATOR MINDELIMITER=',';
255  /**macro variables**/
256  %let fnctl_cmpnt=GT;
257  %let FILE_TYPE=;
258
259  /*Delete macro variable conditionally*/
260  %macro del_mac_var ;
261
262  %if not(&amp;amp;fnctl_cmpnt   in AD,DQ) %then %do;
263  %symdel FILE_TYPE;
264  %end;
265  %mend;
266  %del_mac_var
267  %put &amp;amp;=FILE_TYPE;
WARNING: Apparent symbolic reference FILE_TYPE not resolved.
FILE_TYPE
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The warning message is because the macro variable file_type has been successfully deleted&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 18:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691043#M210283</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-12T18:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691045#M210285</link>
      <description>Thanks. Any other ways to tackle this? I just wanted to know.&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Oct 2020 18:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691045#M210285</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-10-12T18:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691046#M210286</link>
      <description>&lt;P&gt;Your idea seems pretty straight forward. However, if your question is to do with making a process efficient would lead to far reaching questions as to what and how you are trying to do? Why would you need those macro variables? And then why you want to delete those macro variables considering the fact macro variables are any deleted at the end of the session. It all depends on what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the standpoint of making a macro IN operator to work, the solution is just what was posted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 18:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691046#M210286</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-12T18:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691052#M210289</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp; - What is the reason for deleting the macro variable? In all the years I've been using SAS I've never had a reason to do so. Setting a macro variable to blank, yes, but removing it, no. I'm curious to know why you think you need to do this. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;has demonstrated deleting a macro variable and then trying to refer to it results in log warnings which is not advisable.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 19:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691052#M210289</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-10-12T19:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691158#M210322</link>
      <description>&lt;P&gt;How to handle it without the Options Statement &amp;nbsp;in your code below?&lt;/P&gt;
&lt;PRE&gt;options MINOPERATOR MINDELIMITER=',';
/**macro variables**/
%let fnctl_cmpnt=GT;
%let FILE_TYPE=;

/*Delete macro variable conditionally*/
%macro del_mac_var ;

%if not(&amp;amp;fnctl_cmpnt   in AD,DQ) %then %do;
%symdel FILE_TYPE;
%end;
%mend;
%del_mac_var
%put &amp;amp;=FILE_TYPE;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Oct 2020 08:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691158#M210322</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2020-10-13T08:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally delete macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691167#M210326</link>
      <description>&lt;P&gt;Just splti it into separate conditions, and apply DeMorgans law:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;fnctl_cmpnt ne AD and &amp;amp;fnctl_cmpnt ne DQ %then %do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Oct 2020 08:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-delete-macro-variable/m-p/691167#M210326</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-13T08:37:01Z</dc:date>
    </item>
  </channel>
</rss>

