BookmarkSubscribeRSS Feed
deleted_user
Not applicable
%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.
7 REPLIES 7
Olivier
Pyrite | Level 9
%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 ;
deleted_user
Not applicable
in v9 it's ok, BUT in v8 it would make error .
Olivier
Pyrite | Level 9
I do not have problems, using either version 9 or 8.2 (hot fix bundle 82BX07). What does exactly your error say ?
deleted_user
Not applicable
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 ;
TobyDunn_hotmail_com
Fluorite | Level 6
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.
deleted_user
Not applicable
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 ,
deleted_user
Not applicable
Thanks

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 7 replies
  • 2032 views
  • 0 likes
  • 3 in conversation