Skip to content

sasjs job

The sasjs job command enables developers to perform operations on SAS Viya Jobs.


Before using this command, you will need to:

sasjs job execute

Used to execute a job on the SAS server.


sasjs job <action> <job path> [additional arguments]

Additional arguments may include:

  • --ignoreWarnings (alias -i) - If present and return status only is provided, CLI will return status '0', when the job state is warning.
  • --log (alias -l) - path where the log of the finished job will be saved (if used, -w is implied).
  • --output (alias -o) - path where output of the finished job execution will be saved.
  • --returnStatusOnly (alias -r) - If present and wait flag is provided, CLI will job status only (0 = success, 1 = warning, 2 = error).
  • --source (alieas -s) - Provide the path to an input JSON containing job variables, structured as follows: {"macroVars":{"varname":"value","var2":"val2"}}
  • --target (alias -t) - the target environment in which to deploy the services. If not specified, default target will be used, mentioned in sasjsconfig.json. The target can exist either in the local project configuration or in the global .sasjsrc file.
  • --wait (alias -w) - if present, CLI will wait for job completion.


# run the job using the target defined in sasjs add
sasjs job execute /Public/folder/someJob -l ./jobLog.log -o ./jobOutput.json -t myTarget

This will create a session and run a SAS job. The log and output will be returned as files in the current directory.

# create an input file with macro variables
echo '{"macroVars":{"myMacVar":"my macro value!","macvar2":"another value"}}' > sourcevars.json
# execute the job with the above variables, against the default target
sasjs job execute /Public/folder/someJob -l ./jobLog.log -s ./sourcevars.json