Help using Base SAS procedures

Clear variable values during a SAS session

Reply
N/A
Posts: 0

Clear variable values during a SAS session

Hi can anyone let me know how to clear variable values during a SAS session without closing the session.

Thanks and Regards
Yuvraj
Contributor
Posts: 50

Re: Clear variable values during a SAS session

Hello,

Use %SYMDEL "Deletes the specified variable or variables from the macro global symbol table."

i hope it help Smiley Very Happy
N/A
Posts: 0

Re: Clear variable values during a SAS session

Thanks Bruno for the suggestion ,
but I am looing for something which can be used to Re-intialize all the variables in an SAS session to NULL values.
Super Contributor
Super Contributor
Posts: 3,174

Re: Clear variable values during a SAS session

SAS maintains a view called SASHELP.VMACRO, which you can use/reference to generate %LET statements for this purpose.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Clear variable values during a SAS session

Thank you scott, I checked the Macro and it gave me all the Automatic variables and their values.
As suggested by you, we can use a %LET statement and assign NULL values to them.

but isn't there any thing that can do this automatically without using the %LET statement.

--Thanks
Yuvraj
Super Contributor
Super Contributor
Posts: 3,174

Re: Clear variable values during a SAS session

Just to clarify your question again, please -- you are using SAS (either interactively or batch) and at some point in your application processing you want SAS to change all of your SAS MACRO VARIABLES to be BLANK (essentially no value), correct? I know of no SAS feature/function to convert all current, user-defined SAS macro variables to blank.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Clear variable values during a SAS session

I wasn't sure too of any feature that would do it but they asked me the same question in the interview. Message was edited by: yuvi
Super Contributor
Super Contributor
Posts: 3,174

Re: Clear variable values during a SAS session

Your reference to "clear variable values" could be considered somewhat ambiguous, as I eluded to. The term "variable values" could either mean SAS dataset variables or SAS macro variables.

Scott Barry
SBBWorks, Inc.
Respected Advisor
Posts: 3,777

Re: Clear variable values during a SAS session

Is this what you mean?

[pre]
data delete;
set sashelp.vmacro;
where scope eq: 'G' and name ne: 'SYS';
run;
data _null_;
set delete;
call symdel(name);
run;
[/pre]
N/A
Posts: 0

Re: Clear variable values during a SAS session

I guess this would solve the question of clearing the Macro variable values during an SAS session.

Thanks Scott and data_null_ for your help Message was edited by: yuvi
Super Contributor
Super Contributor
Posts: 3,174

Re: Clear variable values during a SAS session

As was stated in an early reply, %SYMDEL can be used to delete one or more "global" macro variable - it does not blank out macro variables.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 10 replies
  • 6128 views
  • 0 likes
  • 4 in conversation