- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can any one explain me with an example.
Regards,
Sidhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make the macro siimpler and lose the local mvars as it closes.
There are many ways to eliminate such a problem.
good luck
PeterC
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
****************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****************************************
I know this is an old thread but I found it unanswered and then figured out a solution.
%macro _localvaltest ();
/*setting up a local macro variable and putting it into a dataset*/
%let localvar=1;
data new;
set sashelp.shoes;
local=&localvar;
run;
/*creating a set that contains currently defined macro variables*/
data vars;
set sashelp.vmacro;
run;
/*write local vars to the log*/
%put _local_;
%put localvar value is &localvar;
/*executing a null step that deletes local variables from the macro table*/
data _null_;
set vars;
if scope='_LOCALVALTEST' then call execute ('%symdel '||trim(left(name))||';');
run;
/*write local vars to the log after the delete - does not show any and comes back unresolved for second put*/
%put _local_;
%put localvar value is &localvar;
/*creating a new set that shows the local macro variable has been deleted by the previous step*/
data vars2;
set sashelp.vmacro;
run;
%mend;
%_localvaltest;
Message was edited by: Scott Moore; Updated to correct syntax error and add %put statemets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
I don't think that's a solution. I'm getting all kinds of errors, starting with the first comment which is missing a / at the end. So as posted everything except the last data step is commented out.
It would be quite surprising if you could trick %SYMDEL into deleting a local variable.
If you play with this more and it still looks like you have deleted a local macro variable, I woud suggest:
1. ) add %put _local_ ; before and after your deletion, to show the change
2. ) turn on options MPRINT and run the code in batch (so you know you have a clean session)
3. ) post the log from that session (showing both the macro definition and the execution.
Kind Regards,
--Q.
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you have SAS/EG use Copy HTML Source to Clipboard then click HTML in "this" editor and past.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do another test and make a global version of the local macro variable you are trying to delete. Which one gets deleted?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
My EG install is broken and getting IT to reinstall is such a hassle that I just use the enhanced editor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
*create variable;
%let var = 1;
*display;
%put varibale var has been create and the value is &var;
*further proof;
data view_var_b4;
set sashelp.vmacro;
run;
*create macro;
%macro del_var (del=);
%symdel &del;
%mend del_var;
*run macro;
%del_var (del=var);
*check variable table
data view_var_after;
set sashelp.vmacro;
run;
*further proof;
%put _user_;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What about simply saying;
%let mvar=;