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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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