BookmarkSubscribeRSS Feed
shivagujjaru
Calcite | Level 5

Hi guys, I need to delete a temporary variable. Created by using select distinct variable name into: variable1.

 

How can I delete this variable1 from work lib .

6 REPLIES 6
Kurt_Bremser
Super User

This is not a temporary variable (these can exist in data steps), but a macro variable (select into in SQL creates macro variables).

Use the %symdel statement to remove unwanted macro variables.

PeterClemmensen
Tourmaline | Level 20

variable1 is a macro variable.. Google search for "delete macro variable" will give you plenty of answers

shivagujjaru
Calcite | Level 5
Adding a point Symdel delete global macro variable . But I have created local macro variable. Thanks alot guys
Tom
Super User Tom
Super User

@shivagujjaru wrote:
Adding a point Symdel delete global macro variable . But I have created local macro variable. Thanks alot guys

Why would you need to delete a local macro variable?  It will disappear when the macro finishes.

shivagujjaru
Calcite | Level 5
I have applied some loop inside the macro . It's like when file is not exits it's still using the local macro variable while checking a condition. Thanks , now it's working
Tom
Super User Tom
Super User

@shivagujjaru wrote:
I have applied some loop inside the macro . It's like when file is not exits it's still using the local macro variable while checking a condition. Thanks , now it's working

When you use INTO in PROC SQL and the query returns no observations then the macro variable is not created (or modified).

Set the macro variable to a value BEFORE the query.

%let list=;
select x into :list separated by ' ' from have where condition;

You can also use the automatic macro variable SQLOBS to see how many observations where selected.

%let n=&sqlobs;
%do i=1 %to &n;
  %let next=%scan(&list,&i,%str( ));
....

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1443 views
  • 0 likes
  • 4 in conversation