Help using Base SAS procedures

deleting list of macro variables

Reply
Frequent Contributor
Frequent Contributor
Posts: 79

deleting list of macro variables

Hello, I have a list of macro variables specified as below

proc sql noprint;

select count(distinct date) into :Num_Dates from &ds1;

select distinct date into : Date1-Smiley Very Happyate%left(&Num_Dates)

from &ds1;

quit;

Is there a way to delete Date1 etc without having to list of all of them I normally use %symdel Thank you!

Trusted Advisor
Posts: 3,215

Re: deleting list of macro variables

Put your processing in a macro. All defined macro variables will  become in the scope local.

When the macro execution stops all local variables are deleted automatic. Nothing to bother about deleting them.

---->-- ja karman --<-----
Frequent Contributor
Frequent Contributor
Posts: 79

Re: deleting list of macro variables

yes I am doing that but just wanted to know if there was a way for my own reference Thanks!

Respected Advisor
Posts: 3,799

Re: deleting list of macro variables

There is a dictionary view and data step view of macro variables.  You can use that to create the list of variable names you want to delete.

PROC Star
Posts: 1,324

Re: deleting list of macro variables

Here's an approach like _null_ suggested:

data _null_ ;

  set sashelp.vmacro ;

  where scope='GLOBAL' and offset=0 and name like "DATE%" ;

  call execute('%nrstr(%%)symdel '||trim(left(name))||';') ;

run ;

Ask a Question
Discussion stats
  • 4 replies
  • 180 views
  • 0 likes
  • 4 in conversation