Table To SAS (Conversion)

Summary

Converts a table to a SAS dataset.

Usage

  • This tool supports connection to SAS Desktop installed on a local computer or connection to SAS Cloud Analytic Services (CAS). If you're using CAS, the order of the records may change during conversion.

  • The Custom Session Configuration File parameter must be used for remote deployments of SAS, such as Workspace Server, UNIX, and Mainframe. If SAS is installed on the same machine as ArcGIS Pro, the configuration file is not required.

    Learn more about SAS session configurations

  • Provide the SAS dataset in the form libref.tablename in which libref is the name of a SAS or CAS library and tablename is the name of the SAS dataset. For example, SASUSER.MYTABLE references a SAS dataset named MYTABLE in the SASUSER library.

  • SAS libraries, dataset names, and column names are not case sensitive. For example, SASUSER.MYTABLE is treated the same as sasuser.mytable and SASUser.MyTable.

  • The number of records that can be converted depends on the available memory of your computer.

  • For a local SAS deployment, the SASUSER, SASHELP, MAPS, MAPSSAS, and MAPSGFK libraries are available by default. To use a custom library, the libref must be defined in the SAS Autoexec file.

    Learn more about Autoexec configurations

  • When connecting to CAS, you can authenticate your credentials in two ways:

    • Provide your username and password using the CAS Username and Password parameters. The password will be hidden and not accessible through geoprocessing history.
    • Provide an authorization (Authinfo) file using the CAS Authorization (Authinfo) File parameter containing your username and encoded password. This option allows you to avoid retyping your password each time you run the tool.

      To automatically use an Authinfo file each time you use the tool, name the file _authinfo (including the underscore) and save it in the Windows home directory (usually C:\Users\<username>). The file can have any file extension, such as _authinfo.txt or _authinfo.netrc. If the file exists in your home directory, the CAS Authorization (Authinfo) File parameter will automatically populate with the file. This allows you to avoid browsing for the same Authinfo file each time you use the tool.

      The Authinfo file can contain connection information for multiple hosts and ports, but for the simplest case of a single user connecting to a single host and port, the Authinfo file will be a single line with the following syntax:

      default user MYUSERNAME password {SAS004}1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ

      You can encode your password for the file using the PROC PWENCODE SAS procedure.

      Learn more about creating Authinfo files and encoding passwords

  • The WORK library is a temporary workspace that is created when a SAS session starts, and all files are deleted when the session closes. This tool starts and closes a new SAS session during operation, so you should not use the WORK library in this tool.

Parameters

LabelExplanationData Type
Input Table

The input table.

Table View
Output SAS Dataset (libref.tablename)

The output SAS dataset. Provide the dataset in the form libref.table in which libref is the name of a SAS library and table is the name of the SAS table.

String
Replace SAS Dataset
(Optional)

Specifies whether the output can overwrite an existing SAS dataset.

  • Checked—The output SAS dataset can overwrite an existing dataset.
  • Unchecked—The output SAS dataset cannot overwrite an existing dataset. This is the default.

Boolean
Use Domain and Subtype Descriptions
(Optional)

Specifies whether domain and subtype descriptions will be included in the output SAS dataset.

  • Checked—Domain and subtype descriptions will be included in the output SAS dataset.
  • Unchecked—Domain and subtype descriptions will not be included in the output SAS dataset. This is the default.

Boolean
Upload SAS Dataset to SAS Cloud Analytic Services (CAS)
(Optional)

Specifies whether the output SAS dataset will be uploaded to CAS or saved in a local SAS library.

  • Checked—The output SAS dataset will be uploaded to CAS.
  • Unchecked—The output SAS dataset will be saved in a local SAS library. This is the default.

Boolean
CAS Hostname URL
(Optional)

The URL of the CAS host.

String
Port
(Optional)

The port of the CAS connection.

Long
CAS Username
(Optional)

The username for the CAS connection.

String
Password
(Optional)

The password for the CAS connection. This password is hidden and not accessible after running the tool.

String Hidden
Custom Session Configuration File
(Optional)

The file specifying custom configurations for the SAS session. The file is only required for customized local or remote SAS deployments.

File
CAS Authorization (Authinfo) File
(Optional)

The file containing authentication information when connecting to CAS. The file must contain the username and encoded password for the connection. If a file is provided, the CAS Username and Password parameters do not need to be specified.

File

arcpy.conversion.TableToSAS(in_table, out_sas_dataset, {replace_sas_dataset}, {use_domain_and_subtype_description}, {use_cas_connection}, {hostname}, {port}, {username}, {password}, {custom_cfg_file}, {authinfo_file})
NameExplanationData Type
in_table

The input table.

Table View
out_sas_dataset

The output SAS dataset. Provide the dataset in the form libref.table in which libref is the name of a SAS library and table is the name of the SAS table.

String
replace_sas_dataset
(Optional)

Specifies whether an existing SAS dataset will be overwritten in the output.

  • OVERWRITEThe output SAS dataset can overwrite an existing dataset.
  • NO_OVERWRITEThe output SAS dataset cannot overwrite an existing dataset.. This is the default.
Boolean
use_domain_and_subtype_description
(Optional)

Specifies whether domain and subtype descriptions will be included in the output SAS dataset.

  • USE_DOMAINDomain and subtype descriptions will be included in the output SAS dataset.
  • NO_DOMAINDomain and subtype descriptions will not be included in the output SAS dataset. This is the default.
Boolean
use_cas_connection
(Optional)

Specifies whether the output SAS dataset will be uploaded to CAS or saved in a local SAS library.

  • USE_CASThe output SAS dataset will be uploaded to CAS.
  • LOCAL_SASThe output SAS dataset will be saved in a local SAS library. This is the default.
Boolean
hostname
(Optional)

The URL of the CAS host.

String
port
(Optional)

The port of the CAS connection.

Long
username
(Optional)

The username for the CAS connection.

String
password
(Optional)

The password for the CAS connection. This password is hidden and not accessible after running the tool.

String Hidden
custom_cfg_file
(Optional)

The file specifying custom configurations for the SAS session. The file is only required for customized local or remote SAS deployments.

File
authinfo_file
(Optional)

The file containing authentication information when connecting to CAS. The file must contain the username and encoded password for the connection. If a file is provided, the username and password parameters do not need to be specified.

File

Code sample

TableToSAS example 1 (Python window)

The following Python window script demonstrates how to use the TableToSAS function with a local SAS installation.


import arcpy
arcpy.conversion.TableToSAS("MyData", "sasuser.MySASData", "OVERWRITE",
                            "USE_DOMAIN", "LOCAL_SAS")
TableToSAS example 2 (stand-alone script)

The following stand-alone Python script demonstrates how to use the TableToSAS function using a connection to CAS.


# Import system modules
import arcpy
import getpass

# Provide tool parameters
in_table = "MyData"
out_SASDS = "casuser.MySASData"
replace_output = "OVERWRITE"
field_domains = "USE_DOMAIN"
connection = "USE_CAS"
hosturl = https://XXX.vdp.sas.com/XXX-XXXXX-default-http/ 
port = 100
username = "CAS_user"

# Provide password securely
password = getpass.getpass()

try:
    # Set the workspace and run the tool.
    arcpy.env.workspace = r"C:\\TableToSAS\\MyData.gdb"
    arcpy.conversion.TableToSAS(in_table, out_SASDS, replace_output, 
                                field_domains, connection, hosturl, port, 
                                username, password)
except arcpy.ExecuteError:
    # If an error occurred when running the tool, print the error message.
    print(arcpy.GetMessages())

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics