Nested Program Blocks (R)

From within R, you can nest program blocks by submitting command syntax that contains a BEGIN PROGRAM block. To nest a program block, include the nested block in a separate command syntax file and submit an INSERT command to read in the block as in:

spsspkg.Submit("INSERT FILE='/myprograms/nested_block.sps'.")

The file /myprograms/nested_block.sps would contain a BEGIN PROGRAM block, as in:

BEGIN PROGRAM R.
<R code>
END PROGRAM.
Note:
  • You can have up to five levels of nesting.
  • R variables (except variables that are specified within functions) that are specified in a nested R program block are global.
  • Nested program blocks can be R program blocks or Python program blocks.