BookmarkSubscribeRSS Feed
FrancisDsa
Calcite | Level 5

I use the below Disconnect button to reset in SAS EG.

How can i do it using SAS code?

Disconnect.PNG

6 REPLIES 6
nhvdwalt
Barite | Level 11

Hi @FrancisDsa

 

Why do you need it to be done via code ?

FrancisDsa
Calcite | Level 5
I am calling a standard macro which sets various libnames, macro variables on a trial folder. I would like it to reset it every time i use.
Example:


%access(trl_id=6545);
nhvdwalt
Barite | Level 11

So it seems like we're dealing with two different things here:

 

1.) Starting and stopping a SAS Workspace Server

2.) Setting some variables within the session once it running 

 

Is this correct ?

Patrick
Opal | Level 21

@FrancisDsa

The ABORT statement would allow you to terminate a SAS Session programmatically within a SAS data step;

There is also the global statement ENDSAS; which you just could issue at the end of your program.

 

Both these statement are quite "brutal" and you'd normally only use them if something goes wrong and you really want to kill the session.

Capture.JPG

 

As I understand it what you want to do is just to re-assign/recreate "stuff" whenever you call a specific macro.

Ideally the macro code/logic does this for you. IF the macro hasn't build in logic to only issue commands if they haven't been issues already earlier in another call (=checks for macro variables and librefs already existing) then I'd assume if you just call the macro with another parameter things work already as you need it.

Sooo... What's the issue/the problem you need to solve?

FrancisDsa
Calcite | Level 5

Its a Standard macro controlled by a group which i cant change.

It looks for a read only global macro variable.
%if %symexist(__dm_initial_sasautos__) %then %do;
%put MESS: ***** Macro &sysmacroname already run. Previous values are used;
%goto final_end;
%end;


The only way is to reset is to Disconnect SAS EG.
However i would like to use Standard macro and instead of asking enduser to Disconnect everytime you run, I would like to handle it programmatically

%SYMDEL __dm_initial_sasautos__;(will not work)
%access(trl_id=6545);

Patrick
Opal | Level 21

@FrancisDsa

Then I guess you've got only two options.

A) Talk to the people maintaining this macro and ask if they could provide an additional parameter to allow for the macro to re-execute on request.

B) Copy the macro code and change the logic to what you need it to be, then issue the macro code at the beginning of your program. That should compile it into WORK which comes quite early in the macro search path (SASAUTOS) so you should pick-up your macro version when calling it.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3549 views
  • 0 likes
  • 3 in conversation