RoyalTS
RoyalTS

Reputation: 10203

execute rsubmit statements locally

I have a number of .sas scripts that are meant to be run locally and that submit jobs to a remote server using rsubmit-endrsubmit blocks. When trying to run the script on the remote server itself SAS Enterprise Guide stumbles over these statements and complains:

ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id.
NOTE: Subsequent lines will be ignored until ENDRSUBMIT.

Is there any way to tell SAS so simply execute the code blocks locally?

Upvotes: 0

Views: 1290

Answers (2)

Joe
Joe

Reputation: 63424

RSUBMIT can also use a connection to the local server. This is commonly done when implementing multiprocessing. You can see examples of it pretty commonly on the net, for example at Michelle Buchecker's Hands on Workshop.

If you want to do that, you can set up site-specific connection scripts where on the local PC the connection script says to connect to the Unix server, and on the Unix server the connection script ... still says to connect to that Unix server. Then just make sure you've named those connections identically, so it uses the right one when it's on the local machine vs on the server.

Note - This may or may not be the right solution for you, depending on why you're running this from the server. If you're just transitioning it to be run always from the server, just get rid of the RSUBMITS. If you're wanting to run it sometimes from one place sometimes from the other, then whether you do what Reeza says (use %if etc. to control whether RSUBMIT is executed or not) or this answer depends on the rest of your code. If it will be simpler to modify to just %if out things, do that; if it will be simpler to allow the RSUBMITs to occur, do that (such as if you have extensive code using the rsubmit-work directory to do things, etc.)

Upvotes: 0

Reeza
Reeza

Reputation: 21274

You need to add macro logic to determine if you need to submit the RSUBMIT lines.

You can use the automatic macro variables: SYSHOSTNAME or SYSENV to determine which system you're on and then use that to control the logic.

%if &syshostname = somevalue %then %do;
          rsubmit .....;
%end;

If you're using SAS 9.4 M5+ you can use %IF/%THEN in oepn code now. You'll have to do some testing and research to determine what value you get in each system and what the exact 'someValue' should be for you.

Upvotes: 2

Related Questions