Page 1 of 1

How can we call REXX from SAS?

Posted: Fri Feb 05, 2016 4:52 pm
by Ranveer Singh
Hi,

Can we call REXX routine from SAS, does anyone can share some example of doing it?

Please consider the following snippets:

Code: Select all

/* REXX */ 
  Arg userprm
  Say 'Parameter passed is' userprm
  Return 0 

JCL for SAS:

Code: Select all

//SAS      EXEC SAS 
//SYSTSPRT DD SYSOUT=* 
//SASREXX  DD  DISP=SHR, 
//             DSN=AB1234.EXEC  
//FILES    DD  * 
AB1234.COBOL                        PQ 
AB1234.EXEC                         ST 
//SYSIN    DD * 
OPTIONS REXXMAC; 
DATA FILES; 
   INFILE FILES; 
   INPUT @2  FILENAME $12. 
         @23 SYSNAME  $4. 
; 
DATA _NULL_; 
SET FILES; 
DO; 
  PUTLOG FILENAME; 
  SASHELLO FILENAME, SYSNAME; 
END; 
PROC PRINT DATA = FILES; 

I expected two messages like this:

Code: Select all

Parameter passed is AB1234.COBOL, PQ 
Parameter passed is AB1234.EXEC,  ST 

But what I get is:

Code: Select all

Parameter passed is FILENAME, SYSNAME 
Please guide.

Re: How can we call REXX from SAS?

Posted: Fri Feb 05, 2016 6:30 pm
by Robert Sample
If you are using the interpreted REXX, then I don't see any way you could call REXX from SAS since there's nothing to call. If your site has the optional REXX compiler (which costs money), you can compile your REXX code and then call the compiled code just like SAS calls a COBOL program or any other compiled load module.

Re: How can we call REXX from SAS?

Posted: Fri Feb 05, 2016 7:17 pm
by enrico-sorichetti
unless I am completely wrong the REXX gets called,

what is wrong is just the way of passing the parameters

Re: How can we call REXX from SAS?

Posted: Mon Feb 08, 2016 1:50 pm
by Ranveer Singh
I had been looking for examples for this. If I find one will post here.

Re: How can we call REXX from SAS?

Posted: Thu Dec 15, 2016 3:33 am
by vasanthz
Hello,

I can see the topic is pretty old, but I don't see straight forward technique on how to do this.
Here is a method as a proof of concept of calling REXX from SAS and passing parameters.
We can call REXX from SAS then do some REXX functions like check the existence of dataset or issue console commands and then pass the control back to SAS.

Code: Select all

//STEP1    EXEC SAS                             
//SASREXX  DD DISP=SHR,DSN=WELLS.REXX.PDS      
//SYSTSPRT DD SYSOUT=*                          
//SYSTSIN  DD DUMMY                             
//SYSIN    DD   *                               
 OPTIONS REXXMAC;                               
 %LET LOLZ_PARMZ = WELLS.LOLZ.PARAMETER;                 
 REXXLOLZ;                                      
/*             
Contents of WELLS.REXX.PDS(REXXLOLZ)

Code: Select all

/*REXX*/                                                    
ADDRESS SAS "DATA _NULL_; "                                 
"LOLZ_PARMZ = SYMGET('LOLZ_PARMZ');"                            
"CALL PUTEXEC('LOLZ_PARMZ',LOLZ_PARMZ);"                        
"RUN;"                                                                   
SAY 'THE PARAMETER BEING PASSED IS ' LOLZ_PARMZ;     
EXIT 
Output:

Code: Select all

THE PARAMETER BEING PASSED IS  WELLS.LOLZ.PARAMETER 
Hope it helps someone in the future.

Re: How can we call REXX from SAS?

Posted: Sat Dec 24, 2016 1:50 pm
by Ranveer Singh
vasanthz wrote:I can see the topic is pretty old, but I don't see straight forward technique on how to do this.
Here is a method as a proof of concept of calling REXX from SAS and passing parameters.
We can call REXX from SAS then do some REXX functions like check the existence of dataset or issue console commands and then pass the control back to SAS.
Thanks for the example vasanthz. This is helpful.