Invoke SAS Code through %Include Remotely

Reply
Contributor
Posts: 27

Invoke SAS Code through %Include Remotely

Hi All,

 

I have to run sas code between RSUBMIT AND ENDRSUBMIT. 

 

The below 3 lines of code I will submit, it will call another program which is again stored in server itself. so I need to put that in between rsubmit and endrsubmit again. However I am getting error when I submit this as,

 

"ERROR: Invalid or unspecified remote session ID. Set OPTIONS REMOTE=session_id. Please help me to overcome this.

 

NOte: This is just a sample code, I have different programs in which I need to include multiple programs where those programs have lengthy of code between multiple rsubmit and endrsubmit statements.

"

rsubmit;

%include '/users/Startupcode.sas';

endrsubmit;

 

Startupcode.sas:

 

rsubmit;
data pathchk;
infile '/users/configfile.txt' dlm='$$$$$$$$$';
input var1 :$150.;
run;

endrsubmit;

Valued Guide
Posts: 540

Re: Invoke SAS Code through %Include Remotely

Hi @Hari2,

 

If you rsubmit an rsubmit statement than that second rsubmit gets executed on the remote server. And thus it will only work if that remote server is itself also connected to a SAS/Connect session via signon. The message you see indicates that is not the case.

 

I would need more detail on what needs to run where in order to help you figure out the proper way of doing things.

 

Kind regards,

- Jan.

Contributor
Posts: 27

Re: Invoke SAS Code through %Include Remotely

Posted in reply to jklaverstijn

Hi Jan,

 

Thanks.

 

basically, I need to call a program from another program through #include method and both the programs should be submitted to server. And, all programs are saved in server location.

So here, when I submit Program 1, it is running fine. and to invoke 2nd program through #include method , since it is saved in server path , I need to put #include statement b/n rsub and endrsub. but the 2nd program, again has sas code between rsubmit and endrsubmit statemnts. So here the issue is coming.

 

Thanks,

Hari.

 

Super User
Posts: 10,571

Re: Invoke SAS Code through %Include Remotely

Code between rsubmit and endrsubmit needs a connection to another SAS/CONNECT session. If that is not there, it won't work, period. Either set up that required session on the server-side session before the %include, or delete the rsubmit/endrsubmit from the include.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Valued Guide
Posts: 540

Re: Invoke SAS Code through %Include Remotely

Do I correctly rephrase your question as:

 

"I have code in an external .sas file and want that rsubmitted."

 

?

 

If so, there is no straightforward syntax to do that that I know of. (Would be nice if there was, though). Can't you add the rsubmit/endrsubmit pair to the file you %include? Otherwise, how about running a datastep that reads your SAS code into a temp file with rsubmit/endrsubmit added and then %include that temp file?

 

Untested:

 

filename runme temp;
filename source '...';
data _null_;
   infile source end=eof; 
   put runme;
   if _n_=1 then put ' rsubmit';
   input;
   put _infile_;
   if (eof) then put 'endrsubmit;';
run;
%include runme;

Hope this helps,

- Jan.

Ask a Question
Discussion stats
  • 4 replies
  • 175 views
  • 0 likes
  • 3 in conversation