Skip to content

sasjs add

The sasjs add command provides a series of prompts used to define a SAS target along with the relevant connection details (if SAS Viya).


sasjs add

sasjs add cred -t targetname # add creds for existing target


Local or Global Config

The first prompt requests scope. If Local is chosen, the target configuration will be added in the /sasjs/sasjsconfig.json file, and any credentials (eg tokens) will be saved in a .env.[targetName] file in the current SASjs project directory.

If Global is chosen, the target configuration will be added to a .sasjsrc file in the users home directory. The sasjs command will look for a target here if executed outside of a SASjs project.

Server Type

The second prompt requests a server type. Options:

  1. SAS Viya - works on 3.5 and 4
  2. SAS 9 - to execute code on SAS 9
  3. SASjs - for deploying to SASjs Server

Target Name

Choose a name for your target. Nearly every SASjs command will take this as input, so you might want to keep it short.

Target Server URL

This is the protocol / servername / port of your target, for instance:

SAS Viya Specific

If SAS Viya was chosen as the server type you will be prompted for a Viya Client ID and secret - this is used for connecting to the SAS Viya REST APIs. To autogenerate these you can also check out the Viya Token Generator.

Once you have entered the client and secret, you will be given a link - click this to generate the authorisation code (one time step).

The token will eventually expire - the majority of commands will show the link again at this point to refresh the token. To avoid this happening in batch, be sure your token remains valid, eg by setting a longer expiry period.

SAS 9 Specific

If SAS 9 was chosen as the serverType then the server name should be chosen (eg SASApp) and the metadata repository in which to deploy the SAS Web Services. Default is Foundation.