<?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: how to delete a macro variable created inside a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50864#M10661</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
so why the value of 'adjust_session' will not change when I=2 and takes the value of new_session as whenI=1. I know that I is not the problem since I change in my output from 1 to 2 , but adjust_session will have always the same value as when I=1???&lt;BR /&gt;
&lt;BR /&gt;
%do I=1 %TO &amp;amp;NOBSI;&lt;BR /&gt;
data _null_; /*rechange to data _NULL_*/&lt;BR /&gt;
set list1 ; &lt;BR /&gt;
if id=&amp;amp;i then do;&lt;BR /&gt;
put new_session=;&lt;BR /&gt;
call symput('adjust_session',new_session);</description>
    <pubDate>Thu, 14 Apr 2011 20:38:59 GMT</pubDate>
    <dc:creator>sasuser1000</dc:creator>
    <dc:date>2011-04-14T20:38:59Z</dc:date>
    <item>
      <title>how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50862#M10659</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to delete the value stored inside a macro variable that I have created inside the following macro . the reason why want to delete the value stored inside adjust_session is because when I=1 , adjust_session get the value of 2, but when I=2 'adjust_session' stay with the same value as when I=1.&lt;BR /&gt;
&lt;BR /&gt;
%macro ADJUST(NOBSI);&lt;BR /&gt;
&lt;BR /&gt;
%local i;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%do I=1 %TO &amp;amp;NOBSI;&lt;BR /&gt;
  data _null_; /*rechange to data _NULL_*/&lt;BR /&gt;
  set list1 ; &lt;BR /&gt;
  if id=&amp;amp;i then do;&lt;BR /&gt;
  put new_session=;&lt;BR /&gt;
  call symput('adjust_session',new_session); &lt;BR /&gt;
  end;&lt;BR /&gt;
  stop; &lt;BR /&gt;
run;&lt;BR /&gt;
.......ETC&lt;BR /&gt;
%symdel adjust_session y product; &lt;BR /&gt;
%end; &lt;BR /&gt;
%mend; &lt;BR /&gt;
%adjust(&amp;amp;nobsi)&lt;BR /&gt;
&lt;BR /&gt;
LOG&lt;BR /&gt;
&lt;BR /&gt;
MLOGIC(ADJUST):  %SYMDEL  ADJUST_SESSION &lt;BR /&gt;
&lt;BR /&gt;
WARNING: Attempt to delete macro variable ADJUST_SESSION failed. Variable not found.</description>
      <pubDate>Thu, 14 Apr 2011 19:58:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50862#M10659</guid>
      <dc:creator>sasuser1000</dc:creator>
      <dc:date>2011-04-14T19:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50863#M10660</link>
      <description>%SYMDEL is only to delete global variables.&lt;BR /&gt;
No need to delete local macro variables, since they are removed automatically when macro ends.</description>
      <pubDate>Thu, 14 Apr 2011 20:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50863#M10660</guid>
      <dc:creator>ASASProgrammer</dc:creator>
      <dc:date>2011-04-14T20:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50864#M10661</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
so why the value of 'adjust_session' will not change when I=2 and takes the value of new_session as whenI=1. I know that I is not the problem since I change in my output from 1 to 2 , but adjust_session will have always the same value as when I=1???&lt;BR /&gt;
&lt;BR /&gt;
%do I=1 %TO &amp;amp;NOBSI;&lt;BR /&gt;
data _null_; /*rechange to data _NULL_*/&lt;BR /&gt;
set list1 ; &lt;BR /&gt;
if id=&amp;amp;i then do;&lt;BR /&gt;
put new_session=;&lt;BR /&gt;
call symput('adjust_session',new_session);</description>
      <pubDate>Thu, 14 Apr 2011 20:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50864#M10661</guid>
      <dc:creator>sasuser1000</dc:creator>
      <dc:date>2011-04-14T20:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50865#M10662</link>
      <description>I would try either removing the stop statement or use point in the set statement(and get rid of the if statement).  According to the documentation on the STOP statement:&lt;BR /&gt;
&lt;BR /&gt;
The STOP statement causes SAS to stop processing the current DATA step immediately and resume processing statements after the end of the current DATA step.&lt;BR /&gt;
&lt;BR /&gt;
It looks like the data step will never get past the first observation.</description>
      <pubDate>Thu, 14 Apr 2011 20:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50865#M10662</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-04-14T20:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50866#M10663</link>
      <description>Hello SASUser1000,&lt;BR /&gt;
&lt;BR /&gt;
I've made some small changes in your code and it works as expected (at least in my opinion):&lt;BR /&gt;
[pre]&lt;BR /&gt;
data list1;&lt;BR /&gt;
  do id=1 to 20;&lt;BR /&gt;
    new_session=id**2;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
%macro ADJUST(NOBSI);&lt;BR /&gt;
  %local i adjust_session;&lt;BR /&gt;
  %do I=1 %TO &amp;amp;NOBSI;&lt;BR /&gt;
  data _null_; /*rechange to data _NULL_*/&lt;BR /&gt;
    set list1 ; &lt;BR /&gt;
    if id=&amp;amp;i then do;&lt;BR /&gt;
      put new_session=;&lt;BR /&gt;
      call symputx('adjust_session',new_session); &lt;BR /&gt;
    end;&lt;BR /&gt;
  run;&lt;BR /&gt;
%end; &lt;BR /&gt;
%mend; &lt;BR /&gt;
options mprint mlogic;&lt;BR /&gt;
%adjust(2)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 14 Apr 2011 20:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50866#M10663</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-14T20:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50867#M10664</link>
      <description>RICKM THANK YOU SOOOO MUCH!&lt;BR /&gt;
IT WORKED!</description>
      <pubDate>Thu, 14 Apr 2011 20:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50867#M10664</guid>
      <dc:creator>sasuser1000</dc:creator>
      <dc:date>2011-04-14T20:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to delete a macro variable created inside a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50868#M10665</link>
      <description>Thanks SPR, I will check this.</description>
      <pubDate>Thu, 14 Apr 2011 22:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-delete-a-macro-variable-created-inside-a-macro/m-p/50868#M10665</guid>
      <dc:creator>sasuser1000</dc:creator>
      <dc:date>2011-04-14T22:35:29Z</dc:date>
    </item>
  </channel>
</rss>

