BookmarkSubscribeRSS Feed
bentleyj1
Quartz | Level 8

I'm a new EG user and every day I'm finding things that irritate me. 

 

Upon starting EG I've got it set up to automatically connect to a remote server.  That works fine.  But I also have a second remote server that I sometimes connect to and sometimes I submit code to the local  'server'.

 

How do I (or can I) make it submit server-specific code (an autoexec.sas) the first time I connect to a server?  That is, when I set server serverA as 'active' I want it to automatically run the serverA program and when I set serverB active I want the serverB program to run.

 

These programs contain server-specific options (like sasautos= ) and libname and filename statements.  

 

With my old PC SAS and SAS/Connect it was pretty self-explanatory.  But with EG, the same Tools, Options, SAS Programs, 'submit SAS code when server is connected code' runs for every server.  I've tried putting an autoexec.sas in my home directory on each server but EG appears to ignore it.

 

In the program that's submitted to the servers when they're made active, I tried using a macro with conditional execution based on the value of _SASSERVERNAME to assign a global macro variable holding the server name.  But then checking it with a different program using %put _user_;  doesn't show the global macro variable I tried to create so I assume its not working. 

 

Ha anyone figured out how to do this?  Or is the answer to have a 'project' for each server and manually run it after connecting?

 

Thanks in advance for the help.

 

John

5 REPLIES 5
CaseySmith
SAS Employee

Using _SASSERVERNAME as you described worked for me...

(I used EG 7.15, but I'd expect it to work for any version.)

 

-In EG's Tools->Options->SAS Programs, I checked "Submit SAS code when server is connected" and inserted this code:

 

%put &_SASSERVERNAME;

 

-Then, after connecting to my workspace server ("SASApp" in my case), I checked the workspace server initialization log (right-click the server in the Servers view, select Properties, Software tab, then click View Initialization Log button).

 

At the bottom of the log, it properly printed the _SASSERVERNAME...

 

522 /* Insert custom code after server connection here */
523 %put &_SASSERVERNAME;%let _EG_WORKSPACEINIT=1;
'SASApp'
524

 

So, you should be able to use _SASSERVERNAME in conditional logic in your custom workspace initialization code to submit different code for different servers.

 

Casey

 

Note: If you wanted the same code to be submitted for all users (just different code for each server), I'd recommend adding it to different autoexec.sas files on the server and update the server definitions in metadata to use the different autoexecs.


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

bentleyj1
Quartz | Level 8

Thanks for your help Casey.  I'll give it another try.  I didn't know about the workspace server initialization log (right-click the server in the Servers view, select Properties, Software tab, then click View Initialization Log button). 

 

What does  %let_EG_WORKSPACEINIT=1 do in your custom code?

 

 

Modifying the autoexec.sas on the server and updating the server definitions to use different autoexecs is a great idea but it will never happen here. 

 

John

CaseySmith
SAS Employee

John,

 

Sorry, the "%let_EG_WORKSPACEINIT=1;" is actually part of the EG-generated workspace initialization code, not my custom code.  It appears to be part of my custom code, because I did not enter a carriage-return/line-feed after my custom code.  If I do enter a CRLF after my custom code, then it appears like this in the log:

 

522 /* Insert custom code after server connection here */
523 %put &_SASSERVERNAME;
'SASApp'
524 %let _EG_WORKSPACEINIT=1;

 

The _EG_WORKSPACEINIT macro is simply an internal flag EG uses to indicate/check that workspace initialization has taken place.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

bentleyj1
Quartz | Level 8

I can't find the workspace server initialization log (right-click the server in the Servers view, select Properties, Software tab, then click View Initialization Log button).  It's possible likely that our SAS Admin has turned off initialization logging, or is it possible that the SAS Admin has disabled the run code at startup capability?  Something like that wouldn't surprise me.

 

What I need are some macro variables and librefs assigned at startup so I don't have to assign them manually.   But I don't know that will work because my experience seems to be that macro variables and librefs assigned in one project are not available in another.

 

Thanks.

 

John

 

CaseySmith
SAS Employee

John,

 

Your screenshot is showing the General tab.  Click the Software tab and you should see the View Initialization Log button.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4513 views
  • 1 like
  • 2 in conversation