Why this happens? many thks

Reply
N/A
Posts: 0

Why this happens? many thks

%let a=1;
%let b=2;
%let ab=a b;
%symdel &ab;

the above statements works well, but the below will make error:

%macro test;
%let a=1;
%let b=2;
%let ab=a b;
%symdel &ab;
%mend;
%test;

ERROR: Macro variable name & must start with a letter or underscore.
Super Contributor
Posts: 260

Re: Why this happens? many thks

%SYMDEL only deletes GLOBAL macro-variables, hence does not delete (does not have access to) macro-variables created inside a macro-program (except if declared global when created).
This would work :

%MACRO test ;
%GLOBAL a ;
%GLOBAL b ;
%GLOBAL ab ;
%LET a = 1 ; %LET b = 2 ; %LET ab = a b ;
%SYMDEL &ab ;
%MEND test ;
%test ;
N/A
Posts: 0

Re:

in v9 it's ok, BUT in v8 it would make error .
Super Contributor
Posts: 260

Re: Why this happens? many thks

I do not have problems, using either version 9 or 8.2 (hot fix bundle 82BX07). What does exactly your error say ?
N/A
Posts: 0

Re: Why this happens? many thks

1 %MACRO test ;
2 %GLOBAL a ;
3 %GLOBAL b ;
4 %GLOBAL ab ;
5 %LET a = 1 ; %LET b = 2 ; %LET ab = a b ;
6 %SYMDEL &ab ;
7 %MEND test ;
8 %test ;
ERROR: Macro variable name & must start with a letter or underscore.


BUT Test2 will be ok

19 %MACRO test2 ;
20 %GLOBAL a ;
21 %GLOBAL b ;
22 %GLOBAL ab ;
23 %LET a = 1 ; %LET b = 2 ; %LET ab = a b ;
24 %unquote(%nrstr(%SYMDEL &ab)) ;
25 %MEND test2 ;
26 %test2 ;
Occasional Contributor
Posts: 10

Re: Why this happens? many thks

This is a known bug: http://support.sas.com/techsup/unotes/SN/005/005975.html


Why worry about it, any macro variable that was not previously defined as a global macro variable is local to that macro. Thus, when the macro is finished executing the macro variables goes away. Deleting them is just redundent and makes the code more confusing.
N/A
Posts: 0

Re: Why this happens? many thks

Hi friends,
please advice and guidance to get results and if you interested please attach any programmes otherwise ignore my problem.if you interested please attach my mail id-sudhakar.987@gmail.com


Thank ,
N/A
Posts: 0

Re: Thanks!

Thanks
Ask a Question
Discussion stats
  • 7 replies
  • 638 views
  • 0 likes
  • 3 in conversation