Introduction

SAS Micro Analytic Service 2.1 supports modules that are written in the Python programming language. A Python module represents a Python program, and the module's methods represent the functions within the Python program.
Here is an example of a Python public function that can be hosted by SAS Micro Analytic Service. This example has no output. Input arguments are given in the function's argument list. This example has input variables a and b. Outputs of the function must be listed after "Output:" in the quoted string that follows the function definition. The output variables should match the variables listed in the return statement.
def calcATimesB(a, b):
  "Output: "
  print ("Function with no output variables.")
  c = a * b
  print ("Result is: ", c, ", but is not returned")
  return None
Note: Input and output argument names live in a single namespace. Therefore, they cannot be the same. This means that in_out arguments are not supported. This is true for all module types in SAS Micro Analytic Service. This is not an issue in Python, as a new variable can be assigned the value of an input argument and then safely added to the output list. If the "Output:" line is missing, the function is not exposed as a callable function through SAS Micro Analytic Service. However, that function can be called internally. As a result, any function without the "Output:" line is a private function. The func0() function is an example of such a private function. SAS Micro Analytic Service parses the code to create a dictionary of the methods and their signatures.