Skip to content

Getting started

Stuart Malcolm edited this page Oct 7, 2021 · 2 revisions

This tutorial describes how to get started after installing powerSAS

Local and Remote SAS Sessions

Connect to SAs running locally on developer workstation

    PS> Connect-SAS -Local
    <do stuff>
    PS> Disconnect-SAS

Connect to SAS Academics EU server using Alice username

If the -local flag is not specified, then a Remote connection is assumed, and the default remote server (if none given in the command line - see next example) is the SAS On-Demand EU server odaws01-euw1.oda.sas.com

    PS> Connect-SAS -Credential alice
    Password for user alice: ******

    <do stuff>

    PS> Disconnect-SAS

Connect to company production SAS server

In this example we are connecting to our corporate SAS production server which has and example address of `` and using the Get-Credentials cmdlet to prompt user for all credentials

    PS> Connect-SAS -server sasprod.company.com -credential (Get-Credentials)
    PowerShell credential request
    Enter your credentials.
    User: bob
    Password for user stuart: ****

    <do stuff>

    PS> Disconnect-SAS

Connect to corporate SAS server using credentials supplied as variable

NOTE THIS IS NOT RECOMMENDED, but is supported 'just in case'..

If you need to supply the username and password in a script, then the PS ConvertTo-SecureString can be used to encode the password:

    PS> $password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force
    PS> $Cred = New-Object System.Management.Automation.PSCredential ("carol", $password)
    PS> Connect-SAS -server sas.company.com -credential $Cred

    <do stuff>

    PS> Disconnect-SAS

Execute individual SAS commands from Powershell

The Write-SAS

# send a single command to SAS
PS> "%put &syshostname;" | write-sas
1          %put &syshostname;
odaws01-euw1

Running SAS programs

Interactive SAS

Advanced topics

  • TODO