API Reference

SAS Session Object

class saspy.sasbase.SASsession(**kwargs)

Overview

The SASsession object is the main object to instantiate and provides access to the rest of the functionality. Most of these parameters will be configured in the sascfg_personal.py configuration file. All of these parameters are documented more thoroughly in the Configuration section of the saspy doc: https://sassoftware.github.io/saspy/configuration.html These are generally defined in the sascfg_personal.py file as opposed to being specified on the SASsession() invocation.

Return type:

‘SASsession’

Common parms for all access methods are:

Parameters:
  • cfgname – the Configuration Definition to use - value in SAS_config_names List in the sascfg_personal.py file

  • cfgfile – fully qualified file name of your sascfg_personal.py file, if it’s not in the python search path

  • kernel – None - internal use when running the SAS_kernel notebook

  • results – Type of tabular results to return. default is ‘Pandas’, other options are ‘HTML or ‘TEXT’

  • lrecl – An integer specifying the record length for transferring wide data sets from SAS to DataFrames.

  • autoexec – A string of SAS code that will be submitted upon establishing a connection

  • display – controls how to display html in different notebooks. default is jupyter. valid values are [‘jupyter’, ‘zeppelin’, ‘databricks’]

  • colorLOG – boolean, default False, causes the SASLOG returned from the submit methods to be HTML instead of text (str) and to have ERROR:, WARNING: and NOTE: lines colorized like in other SAS UI’s. This was added in version 5.6.0.

And each access method has its own set of parameters.

STDIO

Parameters:
  • saspath – overrides saspath Dict entry of cfgname in sascfg_personal.py file

  • options – overrides options Dict entry of cfgname in sascfg_personal.py file

  • encoding – This is the python encoding value that matches the SAS session encoding

STDIO over SSH

and for running STDIO over passwordless ssh, add these required parameters

Parameters:
  • ssh – full path of the ssh command; /usr/bin/ssh for instance

  • host – host name of the remote machine

  • identity – (Optional) path to a .ppk identity file to be used on the ssh -i parameter

  • port – (Optional) The ssh port of the remote machine normally 22 (equivalent to invoking ssh with the -p option)

  • tunnel – (Optional) Certain methods of saspy require opening a local port and accepting data streamed from the SAS instance.

  • rtunnel – (Optional) Certain methods of saspy require opening a remote port and accepting data streamed to the SAS instance.

IOM

and for the IOM IO module to connect to SAS9 via Java IOM

Parameters:
  • java – the path to the java executable to use

  • iomhost – for remote IOM case, not local Windows] the resolvable host name, or ip to the IOM server to connect to

  • iomport – for remote IOM case, not local Windows] the port IOM is listening on

  • omruser – user id for remote IOM access

  • omrpw – pw for user for remote IOM access

  • encoding – This is the python encoding value that matches the SAS session encoding of the IOM server you are connecting to

  • classpath – classpath to IOM client jars and saspyiom client jar.

  • authkey – Key value for finding credentials in .authfile

  • timeout – Timeout value for establishing connection to workspace server

  • appserver – Appserver name of the workspace server to connect to

  • sspi – Boolean for using IWA to connect to a workspace server configured to use IWA

  • javaparms – for specifying java command line options if necessary

  • logbufsz – see issue 266 for details on this. not needed normally

  • reconuri – the uri (token) for connecting back to the workspace server after you’ve disconnected. not needed unless connecting back from a different Python process.

HTTP

and for the HTTP Access Method to to connect to SAS in Viya

Parameters:
  • url – The URL to Viya, of the form: http[s]://host.identifier[:port]

  • verify – Flag to have http try to verify the certificate or not

  • client_id – [for SSO Viya configurations] client_id to use for authenticating to Viya (defaults to ‘SASPy’)

  • client_secret – [for SSO Viya configurations] client_secret to use for authenticating to Viya (defaults to ‘’)

  • authcode – [for SSO Viya configurations] one time authorization code acquired via the SASLogon oauth servide where the url to get the code would be [url]/SASLogon/oauth/authorize?client_id=[client_id]i&response_type=code so perhaps: https://SAS.Viya.sas.com/SASLogon/oauth/authorize?client_id=SASPy&response_type=code

  • authkey – Key value for finding credentials in .authfile

  • user – userid for connecting to Viya (Not valid if Viya is configured for SSO - Single Sign On)

  • pw – password for connecting to Viya (Not valid if Viya is configured for SSO - Single Sign On)

  • context – The Compute Server Context to connect to

  • options – SAS options to include when connecting

  • encoding – [deprecated] The Compute Service interface only works in UTF-8, regardless of the SAS encoding

  • timeout – This is passed to the HTTPConnection (http.client) and has nothing to do with Viya or Compute

  • inactive – This is Inactivity Timeout, in minutes, for the SAS Compute Session. It defaults to 120 minutes.

  • ip – [deprecated] The resolvable host name, or IP address to the Viya (use url instead)

  • port – [deprecated] The port to use to connect to Viya (use url instead)

  • ssl – [deprecated] Boolean identifying whether to use HTTPS (ssl=True) or just HTTP (use url instead)

  • authtoken – The SASLogon authorization token to use instead of acquiring one via user/pw or authcode or jwt. Normally SASPy calls SASLogon to authenticate and get this token. But, if you do that yourself, you can pass it in.

  • jwt – A JWT that can be used to acquire a SASLogon authorization token. This would be something like an Azure token, where Azure and Viya have been set up to allow the JWT to be used to get a SASLogon token.

COM

and for IOM IO via COM

Parameters:
  • iomhost – Resolvable host name or IP of the server

  • iomport – Server port

  • class_id – IOM workspace server class identifier

  • provider – IOM provider

  • authkey – Key value for finding credentials in .authfile

  • encoding – This is the python encoding value that matches the SAS session encoding of the IOM server

  • omruser – User

  • omrpw – Password

Common SASsession attributes

The values of the following attributes will be displayed if you submit a SASsession object. These can be referenced programmatically in you code. For the Booleans, you should use the provided methods to set them, or change their value. The others you should NOT change, for obvious reasons.

  • workpath - string containing the WORK libref?s filesystem path.

  • sasver - string of the SAS Version for the SAS server connected to

  • version - string of the saspy version you?re running

  • nosub - Boolean for current value of the teach_me_SAS() setting.

  • batch - Boolean for current value of the batch setting. use set_batch() to change value.

  • results - string showing current value of for session results setting. use set_results() to change value.

  • sascei - string for the SAS Session Encoding this SAS server is using

  • SASpid - The SAS processes id, or None if no SAS session connected

Other attrritubes of the SASsession object that you may use for various purposes.

  • hostsep - simply a forward slash for linux systems and a backslash on windows clients; just for convenience

  • check_error_log - Boolean that identifies an ERROR has been found in the SASLOG. You should set this to False prior to running a saspy method that where you check it after. saspy does not reset it to False for you.

  • reconuri - the uri (token) for connecting back to the workspace server after you’ve disconnected. not needed unless connecting back from a different Python process; not the usual case.

  • HTML_Style - This is the Style for ODS output, set from SAS_output_options {‘style’ : ‘’} value in your config file. You can change this value on the fly by setting the value for this attribute.

Common functions that can be used in the Notebook sessions supported by the `Display` Config setting

  • HTML() - different Notebooks use different ways to identify HTML. This function maps to each Notebooks method. For instance, in Jupyter HTML is the HTML method from IPython.display

  • DISPLAY() - different Notebooks have different ways to render things, like HTML. This function maps to each Notebooks method. For instance, in Jupyter DISPLAY is the display method from IPython.display.

SYSERR()

This method returns the SAS Automatic Macro Variable SYSERR which contains a return code status set by some SAS procedures and the DATA step.

SYSERRORTEXT()

This method returns the SAS Automatic Macro Variable SYSERRORTEXT which is the text of the last error message generated in the SAS log.

SYSFILRC()

This method returns the SAS Automatic Macro Variable SYSFILRC which identifies whether or not the last FILENAME statement executed correctly.

SYSINFO()

This method returns the SAS Automatic Macro Variable SYSINFO which contains return codes provided by some SAS procedures.

SYSLIBRC()

This method returns the SAS Automatic Macro Variable SYSLIBRC which reports whether the last LIBNAME statement executed correctly.

SYSWARNINGTEXT()

This method returns the SAS Automatic Macro Variable SYSWARNINGTEXT which is the text of the last warning message generated in the SAS log.

assigned_librefs() list

This method returns the list of currently assigned librefs

cat(path) str

Like Linux ‘cat’ - open and print the contents of a file

dataframe2sasdata(df: DataFrame, table: str = '_df', libref: str = '', results: str = '', keep_outer_quotes: bool = False, embedded_newlines: bool = True, LF: str = '\x01', CR: str = '\x02', colsep: str = '\x03', colrep: str = ' ', datetimes: dict = {}, outfmts: dict = {}, labels: dict = {}, outdsopts: dict = {}, encode_errors=None, char_lengths=None, **kwargs) SASdata

This method imports a Pandas DataFrame to a SAS Data Set, returning the SASdata object for the new Data Set.

Also note that DataFrame indexes (row label) are not transferred over as columns, as they aren’t actualy in df.columns. You can simpley use df.reset_index() before this method and df.set_index() after to have the index be a column which is transferred over to the SAS data set. If you want to create a SAS index at the same time, use the outdsopts dict.

Parameters:
  • df – Pandas DataFrame to import to a SAS Data Set

  • table – the name of the SAS Data Set to create

  • libref – the libref for the SAS Data Set being created. Defaults to WORK, or USER if assigned

  • results – format of results, SASsession.results is default, PANDAS, HTML or TEXT are the alternatives

As of version 3.5.0, keep_outer_quotes is deprecated and embedded_newlines defaults to True

Parameters:
  • keep_outer_quotes – the defualt is for SAS to strip outer quotes from delimitted data. This lets you keep them

  • embedded_newlines – if any char columns have embedded CR or LF, set this to True to get them imported into the SAS data set

colrep is new as of version 3.5.0

Parameters:
  • LF – if embedded_newlines=True, the chacter to use for LF when transferring the data; defaults to hex(1)

  • CR – if embedded_newlines=True, the chacter to use for CR when transferring the data; defaults to hex(2)

  • colsep – the column separator character used for streaming the delimmited data to SAS defaults to hex(3)

  • colrep – the char to convert to for any embedded colsep, LF, CR chars in the data; defaults to ‘ ‘

  • datetimes – dict with column names as keys and values of ‘date’ or ‘time’ to create SAS date or times instead of datetimes

  • outfmts – dict with column names and SAS formats to assign to the new SAS data set

  • labels – dict with column names and labels to assign to the new SAS data set

  • outdsopts

    a dictionary containing output data set options for the table being created for instance, compress=, encoding=, index=, outrep=, replace=, rename= … the options will be generated simply as key=value, so if a value needs quotes or parentheses, provide them in the value

    {'compress' : 'yes' ,
     'encoding' : 'latin9' ,
     'replace'  : 'NO' ,
     'index'    : 'coli' ,
     'rename'   : "(col1 = Column_one  col2 = 'Column Two'n)"
    }
    

  • encode_errors – ‘fail’, ‘replace’ or ‘ignore’ - default is to ‘fail’, other choice is to ‘replace’ invalid chars with the replacement char. ‘ignore’ doesn’t try to transcode in python, so you get whatever happens in SAS based upon the data you send over. Note ‘ignore’ is only valid for IOM and HTTP

  • char_lengths

    How to determine (and declare) lengths for CHAR variables in the output SAS data set SAS declares lenghts in bytes, not characters, so multibyte encodings require more bytes per character (BPC)

    • ’exact’ - the default if SAS is in a multibyte encoding. calculate the max number of bytes, in SAS encoding, required for the longest actual value. This is slowest but most accurate. For big data, this can take excessive time. If SAS is running in a single byte encoding then this defaults to ‘1’ (see below), but you can override even that by explicitly specifying ‘exact’ when SAS is a single byte encoding.

    • ’safe’ - use char len of the longest values in the column, multiplied by max BPC of the SAS multibyte encoding. This is much faster, but could declare SAS Char variables longer than absolutely required for multibyte SAS encodings. If SAS is running in a single byte encoding then ‘1’ (see below) is used. Norte that SAS has no fixed length multibyte encodings, so BPC is always between 1-2 or 1-4 for these. ASCII characters hex 00-7F use one btye in all of these, which other characters use more BPC; it’s variable

    • [1|2|3|4]- this is ‘safe’ except the number (1 or 2 or 3 or 4) is the multiplier to use (BPC) instead of the default BPC of the SAS session encoding. For SAS single byte encodings, the valuse of 1 is the default used, since characters can only be 1 byte long so char len == byte len For UTF-8 SAS session, 4 is the BPC, so if you know you don’t have many actual unicode characters you could specify 2 so the SAS column lengths are only twice the length as the longest value, instead of 4 times the, which would be much longer than actually needed. Or if you know you have no unicode chars (all the char data is actual only 1 byte), you could specify 1 since it only requires 1 BPC.

    • dictionary - a dictionary containing the names:lengths of all of the character columns. This eliminates running the code to calculate the lengths, and goes strainght to transferring the data

Returns:

SASdata object

datasets(libref: str = '') str

This method is used to query a libref. The results show information about the libref including members.

Parameters:

libref – the libref to query

Returns:

df2sd(df: DataFrame, table: str = '_df', libref: str = '', results: str = '', keep_outer_quotes: bool = False, embedded_newlines: bool = True, LF: str = '\x01', CR: str = '\x02', colsep: str = '\x03', colrep: str = ' ', datetimes: dict = {}, outfmts: dict = {}, labels: dict = {}, outdsopts: dict = {}, encode_errors=None, char_lengths=None, **kwargs) SASdata

This is an alias for ‘dataframe2sasdata’. Why type all that?

Also note that DataFrame indexes (row label) are not transferred over as columns, as they aren’t actualy in df.columns. You can simpley use df.reset_index() before this method and df.set_index() after to have the index be a column which is transferred over to the SAS data set. If you want to create a SAS index at the same time, use the outdsopts dict.

Parameters:
  • dfpandas.DataFrame Pandas DataFrame to import to a SAS Data Set

  • table – the name of the SAS Data Set to create

  • libref – the libref for the SAS Data Set being created. Defaults to WORK, or USER if assigned

  • results – format of results, SASsession.results is default, PANDAS, HTML or TEXT are the alternatives

As of version 3.5.0, keep_outer_quotes is deprecated and embedded_newlines defaults to True

Parameters:
  • keep_outer_quotes – the defualt is for SAS to strip outer quotes from delimitted data. This lets you keep them

  • embedded_newlines – if any char columns have embedded CR or LF, set this to True to get them imported into the SAS data set

colrep is new as of version 3.5.0

Parameters:
  • LF – if embedded_newlines=True, the chacter to use for LF when transferring the data; defaults to hex(1)

  • CR – if embedded_newlines=True, the chacter to use for CR when transferring the data; defaults to hex(2)

  • colsep – the column separator character used for streaming the delimmited data to SAS defaults to hex(3)

  • colrep – the char to convert to for any embedded colsep, LF, CR chars in the data; defaults to ‘ ‘

  • datetimes – dict with column names as keys and values of ‘date’ or ‘time’ to create SAS date or times instead of datetimes

  • outfmts – dict with column names and SAS formats to assign to the new SAS data set

  • labels – dict with column names and labels to assign to the new SAS data set

  • outdsopts

    a dictionary containing output data set options for the table being created for instance, compress=, encoding=, index=, outrep=, replace=, rename= … the options will be generated simply as key=value, so if a value needs quotes or parentheses, provide them in the value

    {'compress' : 'yes' ,
     'encoding' : 'latin9' ,
     'replace'  : 'NO' ,
     'index'    : 'coli' ,
     'rename'   : "(col1 = Column_one  col2 = 'Column Two'n)"
    }
    

  • encode_errors – ‘fail’, ‘replace’ or ‘ignore’ - default is to ‘fail’, other choice is to ‘replace’ invalid chars with the replacement char. ‘ignore’ doesn’t try to transcode in python, so you get whatever happens in SAS based upon the data you send over. Note ‘ignore’ is only valid for IOM and HTTP

  • char_lengths

    How to determine (and declare) lengths for CHAR variables in the output SAS data set SAS declares lenghts in bytes, not characters, so multibyte encodings require more bytes per character (BPC)

    • ’exact’ - the default if SAS is in a multibyte encoding. calculate the max number of bytes, in SAS encoding, required for the longest actual value. This is slowest but most accurate. For big data, this can take excessive time. If SAS is running in a single byte encoding then this defaults to ‘1’ (see below), but you can override even that by explicitly specifying ‘exact’ when SAS is a single byte encoding.

    • ’safe’ - use char len of the longest values in the column, multiplied by max BPC of the SAS multibyte encoding. This is much faster, but could declare SAS Char variables longer than absolutely required for multibyte SAS encodings. If SAS is running in a single byte encoding then ‘1’ (see below) is used. Norte that SAS has no fixed length multibyte encodings, so BPC is always between 1-2 or 1-4 for these. ASCII characters hex 00-7F use one btye in all of these, which other characters use more BPC; it’s variable

    • [1|2|3|4]- this is ‘safe’ except the number (1 or 2 or 3 or 4) is the multiplier to use (BPC) instead of the default BPC of the SAS session encoding. For SAS single byte encodings, the valuse of 1 is the default used, since characters can only be 1 byte long so char len == byte len For UTF-8 SAS session, 4 is the BPC, so if you know you don’t have many actual unicode characters you could specify 2 so the SAS column lengths are only twice the length as the longest value, instead of 4 times the, which would be much longer than actually needed. Or if you know you have no unicode chars (all the char data is actual only 1 byte), you could specify 1 since it only requires 1 BPC.

    • dictionary - a dictionary containing the names:lengths of a the character columns you want to specify (all or some). This eliminates runmning the code to calculate the lengths (if you provide them all), and goes strainght

      to transferring the data. If you only provide some columns, the others will be calculated still. This way you canoverride all or some of them. Also, the column names are now case independent.

Returns:

SASdata object

df_char_lengths(df: DataFrame, encode_errors=None, char_lengths=None, **kwargs) dict

This is a utility method for df2sd, use to get the character columns lengths from a DataFrame to use to create a SAS data set. This can be called by the user and the returned dict can be passed in to df2sd via the char_lengths= option. For big DataFrames, this can take a long time, so this can be used to do it once, and then the dictionary returned can be provided to df2sd each time it’s called to avoid recalculating this again.

Parameters:
  • dfpandas.DataFrame Pandas DataFrames to import to a SAS Data Set

  • encode_errors – ‘fail’, ‘replace’ - default is to ‘fail’, other choice is to ‘replace’ invalid chars with the replacement char. This is only when calculating byte lengths, which is dependent upon the value of char_lengths=. When calculating char lengths, this parameter is ignored in this method (encoding is deferred to the data transfer step in df2sd).

  • char_lengths

    How to determine (and declare) lengths for CHAR variables in the output SAS data set SAS declares lenghts in bytes, not characters, so multibyte encodings require more bytes per character (BPC)

    • ’exact’ - the default if SAS is in a multibyte encoding. calculate the max number of bytes, in SAS encoding, required for the longest actual value. This is slowest but most accurate. For big data, this can take excessive time. If SAS is running in a single byte encoding then this defaults to ‘1’ (see below), but you can override even that by explicitly specifying ‘exact’ when SAS is a single byte encoding.

    • ’safe’ - use char len of the longest values in the column, multiplied by max BPC of the SAS multibyte encoding. This is much faster, but could declare SAS Char variables longer than absolutely required for multibyte SAS encodings. If SAS is running in a single byte encoding then ‘1’ (see below) is used. Norte that SAS has no fixed length multibyte encodings, so BPC is always between 1-2 or 1-4 for these. ASCII characters hex 00-7F use one btye in all of these, which other characters use more BPC; it’s variable

    • [1|2|3|4]- this is ‘safe’ except the number (1 or 2 or 3 or 4) is the multiplier to use (BPC) instead of the default BPC of the SAS session encoding. For SAS single byte encodings, the valuse of 1 is the default used, since characters can only be 1 byte long so char len == byte len For UTF-8 SAS session, 4 is the BPC, so if you know you don’t have many actual unicode characters you could specify 2 so the SAS column lengths are only twice the length as the longest value, instead of 4 times the, which would be much longer than actually needed. Or if you know you have no unicode chars (all the char data is actual only 1 byte), you could specify 1 since it only requires 1 BPC.

    • dictionary - a dictionary containing the names:lengths of a subset of the character columns. This will calculate the rest of them and return the full dictionary of columns. This way you can override some of them. Also, the column names are now case independent.

Returns:

SASdata object

dirlist(path) list

This method returns the directory list for the path specified where SAS is running

disconnect()

This method disconnects an IOM session to allow for reconnecting when switching networks See the Advanced topics section of the doc for details

download(localfile: str, remotefile: str, overwrite: bool = True, **kwargs)

This method downloads a remote file from the SAS servers file system.

Parameters:
  • localfile – path to the local file to create or overwrite. If a directory, the file will be created in that directory and be named the same as the remote file’s name

  • remotefile – path to remote file

  • overwrite – overwrite the output file if it exists?

Returns:

dict with 2 keys {‘Success’ : bool, ‘LOG’ : str}

endsas()

This method terminates the SAS session, shutting down the SAS process.

exist(table: str, libref: str = '') bool

Does the SAS data set currently exist

Parameters:
  • table – the name of the SAS Data Set

  • libref – the libref for the Data Set, defaults to WORK, or USER if assigned

Returns:

Boolean True it the Data Set exists and False if it does not

Return type:

bool

file_copy(source_path, dest_path, fileref: str = '_spfinf', quiet: bool = False) dict

This method copies one external file to another on the SAS server side

Parameters:
  • source_path – path to the remote source file to copy

  • dest_path – path for the remote file write to

  • fileref – fileref (first 7 chars of one) to use on the two generated filename stmts

  • quiet – print any messages or not

Returns:

dict with 2 keys {‘Success’ : bool, ‘LOG’ : str}

file_delete(filepath, fileref: str = '_spfinfo', quiet: bool = False) dict

This method deletes an external file or directory on the SAS server side

Parameters:
  • filepath – path to the remote file to delete

  • fileref – fileref to use on the generated filename stmt

  • quiet – print any messages or not

Returns:

dict with 2 keys {‘Success’ : bool, ‘LOG’ : str}

file_info(filepath, results: str = 'dict', fileref: str = '_spfinfo', quiet: bool = False) dict

This method returns a dictionary containing the file attributes for the file name provided

If you would like a Pandas DataFrame returned instead of a dictionary, specify results=’pandas’

lastlog() str

This method is used to get the LOG from the most recetly executed submit() method. That is either a user submitted submit() or internally submitted by any saspy method. This is just a convenience over the saslog() method, to just see the LOG for the last code that was submitted instead of the whole session.

Returns:

SAS log (partial)

Return type:

str

lib_path(libref: str) list
Parameters:

libref – the libref to get the path from

Returns:

list of paths for the libref (supports concatenated libraries); note that some librefs have no path, like database librefs.

list_tables(libref: str = 'work', results: str = 'list') list

This method returns a list of tuples containing MEMNAME, MEMTYPE of members in the library of memtype data or view

If you would like a Pandas DataFrame returned instead of a list, specify results=’pandas’

read_csv(file: str, table: str = '_csv', libref: str = '', results: str = '', opts: Optional[dict] = None) SASdata
Parameters:
  • file – either the OS filesystem path of the file, or HTTP://… for a url accessible file

  • table – the name of the SAS Data Set to create

  • libref – the libref for the SAS Data Set being created. Defaults to WORK, or USER if assigned

  • results – format of results, SASsession.results is default, PANDAS, HTML or TEXT are the alternatives

  • opts – a dictionary containing any of the following Proc Import options(datarow, delimiter, getnames, guessingrows)

Returns:

SASdata object

sasdata(table: str, libref: str = '', results: str = '', dsopts: Optional[dict] = None) SASdata

Method to define an existing SAS dataset so that it can be accessed via SASPy

Parameters:
  • table – the name of the SAS Data Set

  • libref – the libref for the Data Set, defaults to WORK, or USER if assigned

  • results – format of results, SASsession.results is default, Pandas, HTML and TEXT are the valid options

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

Returns:

SASdata object

sasdata2dataframe(table: str, libref: str = '', dsopts: Optional[dict] = None, method: str = 'MEMORY', **kwargs) DataFrame

This method exports the SAS Data Set to a Pandas DataFrame, returning the DataFrame object.

Parameters:
  • table – the name of the SAS Data Set you want to export to a Pandas DataFrame

  • libref – the libref for the SAS Data Set.

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

  • method

    defaults to MEMORY; As of V3.7.0 all 3 of these now stream directly into read_csv() with no disk I/O and have much improved performance. MEM, the default, is now as fast as the others.

    • MEMORY the original method. Streams the data over and builds the DataFrame on the fly in memory

    • CSV uses an intermediary Proc Export csv file and pandas read_csv() to import it; faster for large data

    • DISK uses the original (MEMORY) method, but persists to disk and uses pandas read to import. this has better support than CSV for embedded delimiters (commas), nulls, CR/LF that CSV has problems with

For the MEMORY and DISK methods, the following 5 parameters are also available, depending upon access method

Parameters:
  • rowsep – the row separator character to use; defaults to hex(1)

  • colsep – the column separator character to use; defaults to hex(2)

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

  • errors – this is the parameter to decode(errors=) when reading the stream of data into pandas and converting from bytes to chars. If the variables in the SAS data set have invalid characters (from truncation or other) then you can provide values like ‘replace’ or ‘ignore’ to load the invalid data instead of failing.

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

Pandas DataFrame

sasdata2parquet(parquet_file_path: str, table: str, libref: str = '', dsopts: Optional[dict] = None, pa_parquet_kwargs=None, pa_pandas_kwargs=None, partitioned=False, partition_size_mb=128, chunk_size_mb=4, coerce_timestamp_errors=True, static_columns: Optional[list] = None, rowsep: str = '\x01', colsep: str = '\x02', rowrep: str = ' ', colrep: str = ' ', **kwargs) None

This method exports the SAS Data Set to a Parquet file. This is a user contributed method created to work around data sets that are too large to be able to reside in a data frame; not enough memory for Python to have it in Pandas. So, this writes the data out to a parquet file so it can be instantiated back in Python using Arrow.

Parameters:
  • parquet_file_path – path of the parquet file to create

  • table – the name of the SAS Data Set you want to export to a Pandas Data Frame

  • libref – the libref for the SAS Data Set.

  • dsopts – data set options for the input SAS Data Set

  • pa_parquet_kwargs – Additional parameters to pass to pyarrow.parquet.ParquetWriter (default is {“compression”: ‘snappy’, “flavor”: “spark”, “write_statistics”: False}).

  • pa_pandas_kwargs – Additional parameters to pass to pyarrow.Table.from_pandas (default is {}).

  • partitioned – Boolean indicating whether the parquet file should be written in partitions (default is False).

  • partition_size_mb – The size in MB of each partition in memory (default is 128).

  • chunk_size_mb – The chunk size in MB at which the stream is processed (default is 4).

  • coerce_timestamp_errors – Whether to coerce errors when converting timestamps (default is True).

  • static_columns – List of tuples (name, value) representing static columns that will be added to the parquet file (default is None).

  • rowsep – the row seperator character to use; defaults to ‘’

  • colsep – the column seperator character to use; defaults to ‘’

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

None

sasets() SASets

This methods creates a SASets object which you can use to run various analytics. See the sasets.py module. :return: sasets object

saslib(libref: str, engine: str = ' ', path: Union[str, list] = '', options: str = ' ', prompt: Optional[dict] = None) str
Parameters:
  • libref – the libref to be assigned (or deassigned if providing options=’clear’)

  • engine – the engine name used to access the SAS Library (engine defaults to BASE, per SAS)

  • path – path or list of paths to the library (for engines that take a path parameter)

  • options – other engine or engine supervisor options. Including CLEAR to deassign the library. To deassign a library only provide libref= and options=’clear’.

Returns:

SAS log

saslog() str

This method is used to get the current, full contents of the SASLOG

Returns:

SAS log

Return type:

str

sasml() SASml

This methods creates a SASML object which you can use to run various analytics. See the sasml.py module.

Returns:

sasml object

sasqc() SASqc

This methods creates a SASqc object which you can use to run various analytics. See the sasqc.py module.

Returns:

sasqc object

sasstat() SASstat

This methods creates a SASstat object which you can use to run various analytics. See the sasstat.py module.

Returns:

sasstat object

sasutil() SASutil

This methods creates a SASutil object which you can use to run various analytics. See the sasutil.py module.

Returns:

sasutil object

sasviyaml() SASViyaML

This methods creates a SASViyaML object which you can use to run various analytics. See the SASViyaML.py module.

Returns:

SASViyaML object

sd2df(table: str, libref: str = '', dsopts: Optional[dict] = None, method: str = 'MEMORY', **kwargs) DataFrame

This is an alias for ‘sasdata2dataframe’. Why type all that?

Parameters:
  • table – the name of the SAS Data Set you want to export to a Pandas DataFrame

  • libref – the libref for the SAS Data Set.

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

  • method

    defaults to MEMORY; As of V3.7.0 all 3 of these now stream directly into read_csv() with no disk I/O and have much improved performance. MEM, the default, is now as fast as the others.

    • MEMORY the original method. Streams the data over and builds the DataFrame on the fly in memory

    • CSV uses an intermediary Proc Export csv file and pandas read_csv() to import it; faster for large data

    • DISK uses the original (MEMORY) method, but persists to disk and uses pandas read to import. this has better support than CSV for embedded delimiters (commas), nulls, CR/LF that CSV has problems with

For the MEMORY and DISK methods, the following 5 parameters are also available, depending upon access method

Parameters:
  • rowsep – the row separator character to use; defaults to hex(1)

  • colsep – the column separator character to use; defaults to hex(2)

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

  • errors – this is the parameter to decode(errors=) when reading the stream of data into pandas and converting from bytes to chars. If the variables in the SAS data set have invalid characters (from truncation or other) then you can provide values like ‘replace’ or ‘ignore’ to load the invalid data instead of failing.

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

Pandas DataFrame

sd2df_CSV(table: str, libref: str = '', dsopts: Optional[dict] = None, tempfile: Optional[str] = None, tempkeep: bool = False, opts: Optional[dict] = None, **kwargs) DataFrame

This is an alias for ‘sasdata2dataframe’ specifying method=’CSV’. Why type all that?

Parameters:
  • table – the name of the SAS Data Set you want to export to a Pandas DataFrame

  • libref – the libref for the SAS Data Set.

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

  • tempfile – [deprecated except for Local IOM] [optional] an OS path for a file to use for the local CSV file; default it a temporary file that’s cleaned up

  • tempkeep – [deprecated except for Local IOM] if you specify your own file to use with tempfile=, this controls whether it’s cleaned up after using it

  • opts

    a dictionary containing any of the following Proc Export options(delimiter, putnames)

    • delimiter is a single character

    • putnames is a bool [True | False]

    {'delimiter' : '~',
     'putnames'  : True
    }
    

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

Pandas DataFrame

sd2df_DISK(table: str, libref: str = '', dsopts: Optional[dict] = None, rowsep: str = '\x01', colsep: str = '\x02', rowrep: str = ' ', colrep: str = ' ', **kwargs) DataFrame

This is an alias for ‘sasdata2dataframe’ specifying method=’DISK’. Why type all that?

Parameters:
  • table – the name of the SAS Data Set you want to export to a Pandas DataFrame

  • libref – the libref for the SAS Data Set.

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

  • rowsep – the row separator character to use; defaults to hex(1)

  • colsep – the column separator character to use; defaults to hex(2)

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

  • errors – this is the parameter to decode(errors=) when reading the stream of data into pandas and converting from bytes to chars. If the variables in the SAS data set have invalid characters (from truncation or other) then you can provide values like ‘replace’ or ‘ignore’ to load the invalid data instead of failing.

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

Pandas DataFrame

sd2pq(parquet_file_path: str, table: str, libref: str = '', dsopts: Optional[dict] = None, pa_parquet_kwargs=None, pa_pandas_kwargs=None, partitioned=False, partition_size_mb=128, chunk_size_mb=4, coerce_timestamp_errors=True, static_columns: Optional[list] = None, rowsep: str = '\x01', colsep: str = '\x02', rowrep: str = ' ', colrep: str = ' ', **kwargs) None

This method exports the SAS Data Set to a Parquet file. This is an alias for sasdata2parquet. This is a user contributed method created to work around data sets that are too large to be able to reside in a data frame; not enough memory for Python to have it in Pandas. So, this writes the data out to a parquet file so it can be instantiated back in Python using Arrow.

Parameters:
  • parquet_file_path – path of the parquet file to create

  • table – the name of the SAS Data Set you want to export to a Pandas Data Frame

  • libref – the libref for the SAS Data Set.

  • dsopts – data set options for the input SAS Data Set

  • pa_parquet_kwargs – Additional parameters to pass to pyarrow.parquet.ParquetWriter (default is {“compression”: ‘snappy’, “flavor”: “spark”, “write_statistics”: False}).

  • pa_pandas_kwargs – Additional parameters to pass to pyarrow.Table.from_pandas (default is {}).

  • partitioned – Boolean indicating whether the parquet file should be written in partitions (default is False).

  • partition_size_mb – The size in MB of each partition in memory (default is 128).

  • chunk_size_mb – The chunk size in MB at which the stream is processed (default is 4).

  • coerce_timestamp_errors – Whether to coerce errors when converting timestamps (default is True).

  • static_columns – List of tuples (name, value) representing static columns that will be added to the parquet file (default is None).

  • rowsep – the row seperator character to use; defaults to ‘’

  • colsep – the column seperator character to use; defaults to ‘’

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

None

set_batch(batch: bool)

This method sets the batch attribute for the SASsession object; it stays in effect until changed. For methods that just display results like SASdata object methods (head, tail, hist, series, etc.) and SASresult object results, you can set ‘batch’ to true to get the results back directly so you can write them to files or whatever you want to do with them.

This is intended for use in python batch scripts so you can still get ODS XML5 results and save them to files, which you couldn’t otherwise do for these methods. When running interactively, the expectation is that you want to have the results directly rendered, but you can run this way too; get the objects display them yourself and/or write them to somewhere.

When set_batch ==True, you get the same dictionary returned as from the SASsession.submit() method.

Parameters:

batch – bool True = return dict([LOG, LST]. False = display LST to screen.

set_results(results: str)

This method set the results attribute for the SASsession object; it stays in effect till changed

Parameters:

results – set the default result type for this SASdata object. 'Pandas' or 'HTML' or 'TEXT'.

Returns:

string of the return type

Return type:

str

sil(life=None, rate=None, amount=None, payment=None, out: Optional[object] = None, out_summary: Optional[object] = None)

Alias for simple_interest_loan

simple_interest_loan(life=None, rate=None, amount=None, payment=None, out: Optional[object] = None, out_summary: Optional[object] = None)

Calculate the amortization schedule of a simple interest load given 3 of the 4 variables You must specify 3 of the for variables, to solve for the 4th.

Parameters:
  • life – length of loan in months

  • rate – interest rate as a decimal percent: .03 is 3% apr

  • amount – amount of loan

  • payment – monthly payment amount

Returns:

SAS Lst showing the amortization schedule calculated for the missing variable

submit(code: str, results: str = '', prompt: Optional[dict] = None, printto=False, **kwargs) dict

This method is used to submit any SAS code. It returns the Log and Listing as a python dictionary.

Parameters:
  • code – the SAS statements you want to execute

  • results – format of results. ‘HTML’ by default, alternatively ‘TEXT’

  • prompt

    dict of names and flags to prompt for; create macro variables (used in submitted code), then keep or delete the keys which are the names of the macro variables. The boolean flag is to either hide what you type and delete the macros, or show what you type and keep the macros (they will still be available later).

    for example (what you type for pw will not be displayed, user and dsname will):

    results_dict = sas.submit(
                 """
                 libname tera teradata server=teracop1 user=&user pw=&pw;
                 proc print data=tera.&dsname (obs=10); run;
                 """ ,
                 prompt = {'user': False, 'pw': True, 'dsname': False}
                 )
    

  • printto – this option, when set to True, will cause saspy to issue a ‘proc printto;run;’ after the code that is being submitted. This will ‘undo’ any proc printto w/in the submitted code that redirected the LOG or LST, to return the LOG/LST back to saspy. This is explained in more detail in the doc: https://sassoftware.github.io/saspy/limitations.html

  • loglines – boolean identifying you want the list of dicts for each line that can be returned from the HTTP and IOM APIs

HTTP

These kwargs are available for the HTTP Access Method for cases where long running code is submitted. It’s been observed that HTTP Disconnect failures can be returned, even though subsequent calls still work, when submitting the request to see if the code has finished, so the LOG and LST can then be requested. To work around this issue, two parameters are available; one to have a delay between polling requests, and the other the number of disconnect errors to ignore before returning a failure. The defaults are to delay 0 seconds (so everything doesn’t have a delay that slows down how things run), and 5 disconnect errors. If you submit code that runs for more than a few seconds, you can specify GETstatusDelay=n.n, the number of seconds (maybe 0.5 or 2, or 60 if you job runs for many minutes) to wait before asking Compute if the code finished.

Parameters:
  • GETstatusDelay – Number of seconds to sleep between HTTP calls to poll and see if the submitted code has finished

  • GETstatusFailcnt – Number of disconnect failures to ignore before failing, when polling to see if the submitted code has finished

Returns:

a Dict containing two keys:values, [LOG, LST]. LOG is text and LST is ‘results’ (HTML or TEXT)

NOTE: to view HTML results in the ipykernel, issue: from IPython.display import HTML and use HTML() instead of print()

In Zeppelin, the html LST results can be displayed via print(“%html “+ ll[‘LST’]) to diplay as HTML.

i.e,: results = sas.submit(“data a; x=1; run; proc print;run’)

print(results[‘LOG’]) HTML(results[‘LST’])

submitLOG(code, results: str = '', prompt: Optional[dict] = None, printto=False, **kwargs)

This method is a convenience wrapper around the submit() method. It executes the submit then prints the LOG that was returned.

submitLST(code, results: str = '', prompt: Optional[dict] = None, method: Optional[str] = None, printto=False, **kwargs)

This method is a convenience wrapper around the submit() method. It executes the submit then renders the LST that was returned, as either HTML or TEXT, depending upon results. The method= parameter allows you to adjust what gets returned to suit your needs.

  • listorlog - this is the default as of V3.6.5. returns the LST, unless it’s empty, then it returns the LOG instead (one or the other). Useful in case there’s an ERROR.

  • listonly - this was the default, and returns the LST (will be empty if no output was produced by what you submitted)

  • listandlog - as you might guess, this returns both. The LST followed by the LOG

  • logandlist - as you might guess, this returns both. The LOG followed by the LST

symexist(name: str)
Parameters:

name – [required] name of the macro varable to check for existence

Returns:

bool

symget(name: str, outtype=None)
Parameters:
  • name – [required] name of the macro varable to get

  • outtype – [optional] desired output type of the python variable; valid types are [int, float, str] provide an object of the type [1, 1.0, ‘ ‘] or a string of ‘int’, ‘float’ or ‘str’

symput(name: str, value, quoting='NRBQUOTE')
Parameters:
  • name – name of the macro varable to set

  • value – python variable, that can be resolved to a string, to use for the value to assign to the macro variable

  • quoting – None for ‘asis’ macro definition. Or any of the special SAS quoting function like BQUOTE, NRBQUOTE, QUOTE, NRQUOTE, STR, NRSTR, SUPERQ, … default is NRBQUOTE

teach_me_SAS(nosub: bool)
Parameters:

nosub – bool. True means don’t submit the code, print it out so I can see what the SAS code would be. False means run normally - submit the code.

upload(localfile: str, remotefile: str, overwrite: bool = True, permission: str = '', **kwargs)

This method uploads a local file to the SAS servers file system.

Parameters:
  • localfile – path to the local file

  • remotefile – path to remote file to create or overwrite. If a directory, the file will be created in that directory and be named the same as the local file’s name

  • overwrite – overwrite the output file if it exists?

  • permission – permissions to set on the new file. See SAS Filename Statement Doc for syntax

Returns:

dict with 2 keys {‘Success’ : bool, ‘LOG’ : str}

validvarname(df: DataFrame, version: str = 'v7') DataFrame

Creates a copy of a DataFrame with SAS compatible column names. The version= parameter allows you to choose the compatability setting to use.

Parameters:
  • df – a Pandas DataFrame whose column names you wish to make SAS compatible.

  • version

    select the validvarname version using SAS convention.

    • V7: ensures the following conditions are met:
      • up to 32 mixed case alphanumeric characters are allowed.

      • names must begin with alphabetic characters or an underscore.

      • non SAS characters are mapped to underscores.

      • any column name that is not unique when normalized is made unique by appending a counter (0,1,2,…) to the name.

    • V6: like V7, but column names truncated to 8 characters.

    • upcase: like V7, but columns names will be uppercase.

    • any: any characters are valid, but column names truncated to 32 characters.

Returns:

a Pandas DataFrame whose column names are SAS compatible according to the selected version.

write_csv(file: str, table: str, libref: str = '', dsopts: Optional[dict] = None, opts: Optional[dict] = None) str
Parameters:
  • file – the OS filesystem path of the file to be created (exported from the SAS Data Set)

  • table – the name of the SAS Data Set you want to export to a CSV file

  • libref – the libref for the SAS Data Set being created. Defaults to WORK, or USER if assigned

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs)

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a number - either string or int

    • firstobs is a number - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

  • opts

    a dictionary containing any of the following Proc Export options(delimiter, putnames)

    • delimiter is a single character

    • putnames is a bool [True | False]

    {'delimiter' : '~',
     'putnames'  : True
    }
    

Returns:

SAS log

SAS Data Object

class saspy.sasdata.SASdata(sassession, libref, table, results='', dsopts: Optional[dict] = None)

Overview

The SASdata object is a reference to a SAS Data Set or View. It is used to access data that exists in the SAS session. You create a SASdata object by using the sasdata() method of the SASsession object.

Parms for the sasdata() method of the SASsession object are:

Parameters:
  • table – [Required] the name of the SAS Data Set or View

  • libref – [Defaults to WORK] the libref for the SAS Data Set or View.

  • results – format of results, SASsession.results is default, PANDAS, HTML or TEXT are the alternatives

  • dsopts

    a dictionary containing any of the following SAS data set options(where, drop, keep, obs, firstobs, format):

    • where is a string

    • keep are strings or list of strings.

    • drop are strings or list of strings.

    • obs is a numbers - either string or int

    • firstobs is a numbers - either string or int

    • format is a string or dictionary { var: format }

    • encoding is a string

    {'where'    : 'msrp < 20000 and make = "Ford"' ,
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight' ,
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'] ,
     'obs'      :  20 ,
     'firstobs' : '10' ,
     'format'   : {'money': 'dollar10', 'time': 'tod5.'} ,
     'encoding' : 'latin9'
    }
    

add_vars(vars: dict, out: Optional[object] = None, **kwargs)

Copy table to itesf, or to ‘out=’ table and add any vars if you want

Parameters:
  • vars – REQUIRED dictionayr of variable names (keys) and assignment statement (values) to maintain variable order use collections.OrderedDict Assignment statements must be valid SAS assignment expressions.

  • out – OPTIONAL takes a SASdata Object you create ahead of time. If not specified, replaces the existing table and the current SAS data object still refers to the replacement table.

  • kwargs

Returns:

SAS Log showing what happened

Example:

  1. cars = sas.sasdata(‘cars’, ‘sashelp’)

  2. wkcars = sas.sasdata(‘cars’)

  3. cars.add_vars({‘PW_ratio’: ‘weight / horsepower’, ‘Overhang’ : ‘length - wheelbase’}, wkcars)

  4. wkcars.head()

append(data, force: bool = False)

Append ‘data’ to this SAS Data Set. data can either be another SASdataobject or a Pandas DataFrame, in which case dataframe2sasdata(data) will be run for you to load the data into a SAS data Set which will then be appended to this data set.

Parameters:
  • data – Either a SASdata object or a Pandas DataFrame

  • force – boolean to force appended even if anomolies exist which could cause dropping or truncating

Returns:

SASLOG for this step

assessModel(target: str, prediction: str, nominal: bool = True, event: str = '', **kwargs)

This method will calculate assessment measures using the SAS AA_Model_Eval Macro used for SAS Enterprise Miner. Not all datasets can be assessed. This is designed for scored data that includes a target and prediction columns TODO: add code example of build, score, and then assess

Parameters:
  • target – string that represents the target variable in the data

  • prediction – string that represents the numeric prediction column in the data. For nominal targets this should a probability between (0,1).

  • nominal – boolean to indicate if the Target Variable is nominal because the assessment measures are different.

  • event – string which indicates which value of the nominal target variable is the event vs non-event

  • kwargs

Returns:

SAS result object

attrs()

Get the ATTRN and ATTRC (SAS functions) attributes for the Data Set

Returns:

1 row Pandas DataFrame containiung each of the ATTRN/ATTRC SAS function values for the data set

bar(var: str, title: str = '', label: str = '') object

This method requires a character column (use the contents method to see column types) and generates a bar chart.

Parameters:
  • var – the CHAR variable (column) you want to plot

  • title – an optional title for the chart

  • label – LegendLABEL= value for sgplot

Returns:

graphic plot

columnInfo()

display metadata about the table, size, number of rows, columns and their data type

contents(results=None)

display metadata about the table. size, number of rows, columns and their data type … You can override the format of the output with the results= option for this invocation

Returns:

output

delete(quiet=False)

Delete this data set; the SASdata object is still available

Returns:

SASLOG for this step

describe()

display descriptive statistics for the table; summary statistics.

Returns:

head(obs=5)

display the first n rows of a table

Parameters:

obs – the number of rows of the table that you want to display. The default is 5

Returns:

heatmap(x: str, y: str, options: str = '', title: str = '', label: str = '') object

Documentation link: http://support.sas.com/documentation/cdl/en/grstatproc/67909/HTML/default/viewer.htm#n0w12m4cn1j5c6n12ak64u1rys4w.htm

Parameters:
  • x – x variable

  • y – y variable

  • options – display options (string)

  • title – graph title

  • label

Returns:

hist(var: str, title: str = '', label: str = '') object

This method requires a numeric column (use the contents method to see column types) and generates a histogram.

Parameters:
  • var – the NUMERIC variable (column) you want to plot

  • title – an optional Title for the chart

  • label – LegendLABEL= value for sgplot

Returns:

impute(vars: dict, replace: bool = False, prefix: str = 'imp_', out: Optional[SASdata] = None) SASdata

Imputes missing values for a SASdata object.

Parameters:
  • vars – a dictionary in the form of {‘varname’:’impute type’} or {‘impute type’:’[var1, var2]’}

  • replace

  • prefix

  • out

Returns:

‘SASdata’

info()

Display the column info on a SAS data object

Returns:

Pandas data frame

means()

display descriptive statistics for the table; summary statistics. This is an alias for ‘describe’

Returns:

modify(formats: Optional[dict] = None, informats: Optional[dict] = None, label: Optional[str] = None, renamevars: Optional[dict] = None, labelvars: Optional[dict] = None)

Modify a table, setting formats, informats or changing the data set name itself or renaming variables or adding labels to variables

Parameters:
  • formats – dict of variable names and formats to assign

  • informats – dict of variable names and informats to assign

  • label – string of the label to assign to the data set; if it requires outer quotes, provide them

  • renamevars – dict of variable names and new names tr rename the variables

  • labelvars – dict of variable names and labels to assign to them; if any lables require outer quotes, provide them

Returns:

SASLOG for this step

obs(force: bool = False) int
Parameters:

force – if nobs isn’t availble, set to True to force it to be calculated; may take time

Returns:

int # the number of observations for your SASdata object

partition(var: str = '', fraction: float = 0.7, seed: int = 9878, kfold: int = 1, out: Optional[SASdata] = None, singleOut: bool = True) object

Partition a sas data object using SRS sampling or if a variable is specified then stratifying with respect to that variable

Parameters:
  • var – variable(s) for stratification. If multiple then space delimited list

  • fraction – fraction to split

  • seed – random seed

  • kfold – number of k folds

  • out – the SAS data object

  • singleOut – boolean to return single table or seperate tables

Returns:

Tuples or SAS data object

rename(name: Optional[str] = None)

Rename this data set

Parameters:

name – new name for this data set

Returns:

SASLOG for this step

scatter(x: str, y: list, title: str = '') object

This method plots a scatter of x,y coordinates. You can provide a list of y columns for multiple line plots.

Parameters:
  • x – the x axis variable; generally a time or continuous variable.

  • y – the y axis variable(s), you can specify a single column or a list of columns

  • title – an optional Title for the chart

Returns:

graph object

score(file: str = '', code: str = '', out: Optional[SASdata] = None) SASdata

This method is meant to update a SAS Data object with a model score file.

Parameters:
  • file – a file reference to the SAS score code

  • code – a string of the valid SAS score code

  • out – Where to the write the file. Defaults to update in place

Returns:

The Scored SAS Data object.

series(x: str, y: list, title: str = '') object

This method plots a series of x,y coordinates. You can provide a list of y columns for multiple line plots.

Parameters:
  • x – the x axis variable; generally a time or continuous variable.

  • y – the y axis variable(s), you can specify a single column or a list of columns

  • title – an optional Title for the chart

Returns:

graph object

set_results(results: str)

This method set the results attribute for the SASdata object; it stays in effect till changed results - set the default result type for this SASdata object. ‘Pandas’ or ‘HTML’ or ‘TEXT’.

Parameters:

results – format of results, SASsession.results is default, PANDAS, HTML or TEXT are the alternatives

Returns:

None

sort(by: str, out: object = '', **kwargs) SASdata

Sort the SAS Data Set

Parameters:
  • by – REQUIRED variable to sort by (BY <DESCENDING> variable-1 <<DESCENDING> variable-2 …>;)

  • out – OPTIONAL takes either a string ‘libref.table’ or ‘table’ which will go to WORK or USER if assigned or a sas data object’’ will sort in place if allowed

  • kwargs

Returns:

SASdata object if out= not specified, or a new SASdata object for out= when specified

Example:

  1. wkcars.sort(‘type’)

  2. wkcars2 = sas.sasdata(‘cars2’)

  3. wkcars.sort(‘cylinders’, wkcars2)

  4. cars2=cars.sort(‘DESCENDING origin’, out=’foobar’)

  5. cars.sort(‘type’).head()

  6. stat_results = stat.reg(model=’horsepower = Cylinders EngineSize’, by=’type’, data=wkcars.sort(‘type’))

  7. stat_results2 = stat.reg(model=’horsepower = Cylinders EngineSize’, by=’type’, data=wkcars.sort(‘type’,’work.cars’))

tail(obs=5)

display the last n rows of a table

Parameters:

obs – the number of rows of the table that you want to display. The default is 5

Returns:

to_csv(file: str, opts: Optional[dict] = None) str

This method will export a SAS Data Set to a file in CSV format.

Parameters:
  • file – the OS filesystem path of the file to be created (exported from this SAS Data Set)

  • opts

    a dictionary containing any of the following Proc Export options(delimiter, putnames)

    • delimiter is a single character

    • putnames is a bool [True | False]

    {'delimiter' : '~',
     'putnames'  : True
    }
    

Returns:

to_df(method: str = 'MEMORY', **kwargs) DataFrame

Export this SAS Data Set to a Pandas Data Frame

Parameters:

method

defaults to MEMORY; As of V3.7.0 all 3 of these now stream directly into read_csv() with no disk I/O and have much improved performance. MEM, the default, is now as fast as the others.

  • MEMORY the original method. Streams the data over and builds the dataframe on the fly in memory

  • CSV uses an intermediary Proc Export csv file and pandas read_csv() to import it; faster for large data

  • DISK uses the original (MEMORY) method, but persists to disk and uses pandas read to import. this has better support than CSV for embedded delimiters (commas), nulls, CR/LF that CSV has problems with

For the MEMORY and DISK methods the following 4 parameters are also available, depending upon access method

Parameters:
  • rowsep – the row seperator character to use; defaults to hex(1)

  • colsep – the column seperator character to use; defaults to hex(2)

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Returns:

Pandas data frame

to_df_CSV(tempfile: Optional[str] = None, tempkeep: bool = False, opts: Optional[dict] = None, **kwargs) DataFrame

This is an alias for ‘to_df’ specifying method=’CSV’.

Parameters:
  • tempfile – [deprecated except for Local IOM] [optional] an OS path for a file to use for the local CSV file; default it a temporary file that’s cleaned up

  • tempkeep – [deprecated except for Local IOM] if you specify your own file to use with tempfile=, this controls whether it’s cleaned up after using it

  • opts

    a dictionary containing any of the following Proc Export options(delimiter, putnames)

    • delimiter is a single character

    • putnames is a bool [True | False]

    {'delimiter' : '~',
     'putnames'  : True
    }
    

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Returns:

Pandas data frame

Return type:

‘pd.DataFrame’

to_df_DISK(rowsep: str = '\x01', colsep: str = '\x02', rowrep: str = ' ', colrep: str = ' ', **kwargs) DataFrame

This is an alias for ‘to_df’ specifying method=’DISK’.

Parameters:
  • rowsep – the row seperator character to use; defaults to hex(1)

  • colsep – the column seperator character to use; defaults to hex(2)

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

  • kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Parameters:

kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

Returns:

Pandas data frame

Return type:

‘pd.DataFrame’

to_frame(**kwargs) DataFrame

This is just an alias for to_df()

Parameters:

kwargs

Returns:

Pandas data frame

Return type:

‘pd.DataFrame’

to_json(pretty: bool = False, sastag: bool = False, **kwargs) str

Export this SAS Data Set to a JSON Object PROC JSON documentation: http://go.documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=p06hstivs0b3hsn1cb4zclxukkut.htm&locale=en

Parameters:
  • pretty – boolean False return JSON on one line True returns formatted JSON

  • sastag – include SAS meta tags

  • kwargs

Returns:

JSON str

to_pq(parquet_file_path: str, pa_parquet_kwargs=None, pa_pandas_kwargs=None, partitioned=False, partition_size_mb=128, chunk_size_mb=4, coerce_timestamp_errors=True, static_columns: Optional[list] = None, rowsep: str = '\x01', colsep: str = '\x02', rowrep: str = ' ', colrep: str = ' ', **kwargs) None

This method exports the SAS Data Set to a Parquet file. This is an alias for sasdata2parquet.

Parameters:
  • parquet_file_path – path of the parquet file to create

  • pa_parquet_kwargs – Additional parameters to pass to pyarrow.parquet.ParquetWriter (default is {“compression”: ‘snappy’, “flavor”: “spark”, “write_statistics”: False}).

  • pa_pandas_kwargs – Additional parameters to pass to pyarrow.Table.from_pandas (default is {}).

  • partitioned – Boolean indicating whether the parquet file should be written in partitions (default is False).

  • partition_size_mb – The size in MB of each partition in memory (default is 128).

  • chunk_size_mb – The chunk size in MB at which the stream is processed (default is 4).

  • coerce_timestamp_errors – Whether to coerce errors when converting timestamps (default is True).

  • static_columns – List of tuples (name, value) representing static columns that will be added to the parquet file (default is None).

  • rowsep – the row seperator character to use; defaults to ‘’

  • colsep – the column seperator character to use; defaults to ‘’

  • rowrep – the char to convert to for any embedded rowsep chars, defaults to ‘ ‘

  • colrep – the char to convert to for any embedded colsep chars, defaults to ‘ ‘

Two new kwargs args as of V5.100.0 are for dealing with SAS dates and datetimes that are out of range of Pandats Timestamps. These values will be converted to NaT in the dataframe. The new feature is to specify a Timestamp value (str(Timestamp)) for the high value and/or low value to use to replace Nat’s with in the dataframe. This works for both SAS datetime and date values.

Parameters:
  • tsmin – str(Timestamp) used to replace SAS datetime and dates that are earlier than supported by Pandas Timestamp; pandas.Timestamp.min

  • tsmax – str(Timestamp) used to replace SAS datetime and dates that are later than supported by Pandas Timestamp; pandas.Timestamp.max

  • kwargs – a dictionary. These vary per access method, and are generally NOT needed. They are either access method specific parms or specific pandas parms. See the specific sasdata2dataframe* method in the access method for valid possibilities.

These two options are for advanced usage. They override how saspy imports data. For more info see https://sassoftware.github.io/saspy/advanced-topics.html#advanced-sd2df-and-df2sd-techniques

Parameters:
  • dtype – this is the parameter to Pandas read_csv, overriding what saspy generates and uses

  • my_fmts – bool, if True, overrides the formats saspy would use, using those on the data set or in dsopts=

Returns:

None

top(var: str, n: int = 10, order: str = 'freq', title: str = '') object

Return the most commonly occuring items (levels)

Parameters:
  • var – the CHAR variable (column) you want to count

  • n – the top N to be displayed (defaults to 10)

  • order – default to most common use order=’data’ to get then in alphbetic order

  • title – an optional Title for the chart

Returns:

Data Table

where(where: str) SASdata

This method returns a clone of the SASdata object, with the where attribute set. The original SASdata object is not affected.

Parameters:

where – the where clause to apply

Returns:

SAS data object

Procedure Syntax Statements

class saspy.sasproccommons.SASProcCommons(session, *args, **kwargs)

SAS Results

class saspy.sasresults.SASresults(attrs, session, objname, nosub=False, log='')

Return results from a SAS Model object

ALL()

This method shows all the results attributes for a given object

SAS Procedures

Utility

class saspy.sasutil.SASutil(session, *args, **kwargs)

This class is for SAS BASE procedures to be called as python3 objects and use SAS as the computational engine

This class and all the useful work in this package require a licensed version of SAS.

  1. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc).

  2. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc.

  3. Create a set of valid statements. Here is an example:

    lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}
    

    The case and order of the items will be formated.

  4. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  5. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  6. Add a link to the SAS documentation plus any additional details will be helpful to users

  7. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

hpbin(data: ('SASdata', <class 'str'>) = None, code: str = None, freq: str = None, id: (<class 'str'>, <class 'list'>) = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, performance: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPBIN procedure.

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=prochp&docsetTarget=prochp_hpbin_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required..

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm performance:

The performance variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpimpute(data: ('SASdata', <class 'str'>) = None, code: str = None, freq: str = None, id: str = None, impute: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, performance: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPIMPUTE procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=prochp&docsetTarget=prochp_hpimpute_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm impute:

The impute variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm performance:

The performance variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpsample(data: ('SASdata', <class 'str'>) = None, cls: (<class 'str'>, <class 'list'>) = None, performance: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, var: str = None, procopts: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, stmtpassthrough: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, **kwargs: dict) SASresults

Python method to call the HPSAMPLE procedure.

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=prochp&docsetTarget=prochp_hpsample_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required..

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm performance:

The performance variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm var:

The var variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

univariate(data: ('SASdata', <class 'str'>) = None, by: (<class 'str'>, <class 'list'>) = None, cdfplot: str = None, cls: (<class 'str'>, <class 'list'>) = None, freq: str = None, histogram: str = None, id: (<class 'str'>, <class 'list'>) = None, inset: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, ppplot: str = None, probplot: str = None, qqplot: str = None, var: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the UNIVARIATE procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=procstat&docsetTarget=procstat_univariate_syntax.htm&locale=en

The PROC UNIVARIATE statement invokes the procedure. The VAR statement specifies the numeric variables to be analyzed, and it is required if the OUTPUT statement is used to save summary statistics in an output data set. If you do not use the VAR statement, all numeric variables in the data set are analyzed. The plot statements (CDFPLOT, HISTOGRAM, PPPLOT, PROBPLOT, and QQPLOT) create graphical displays, and the INSET statement enhances these displays by adding a table of summary statistics directly on the graph. You can specify one or more of each of the plot statements, the INSET statement, and the OUTPUT statement. If you use a VAR statement, the variables listed in a plot statement must be a subset of the variables listed in the VAR statement.

You can specify a BY statement to obtain separate analyses for each BY group. The FREQ statement specifies a variable whose values provide the frequency for each observation. The ID statement specifies one or more variables to identify the extreme observations. The WEIGHT statement specifies a variable whose values are used to weight certain statistics.

You can use a CLASS statement to specify one or two variables that group the data into classification levels. The analysis is carried out for each combination of levels in the input data set, or within each BY group if you also specify a BY statement. You can use the CLASS statement with plot statements to create comparative displays, in which each cell contains a plot for one combination of classification levels.

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can be a string or list type.

Parm cdfplot:

The cdfplot variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm freq:

The freq variable can only be a string type.

Parm histogram:

The histogram variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm inset:

The inset variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm ppplot:

The ppplot variable can only be a string type.

Parm probplot:

The probplot variable can only be a string type.

Parm qqplot:

The qqplot variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

Machine Learning (SAS Enterprise Miner)

class saspy.sasml.SASml(session, *args, **kwargs)

This class is for SAS Enterprise Miner procedures to be called as python3 objects and use SAS as the computational engine

This class and all the useful work in this package require a licensed version of SAS.

  1. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc).

  2. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc.

  3. Create a set of valid statements. Here is an example:

    lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}
    

    The case and order of the items will be formated.

  4. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  5. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  6. Add a link to the SAS documentation plus any additional details will be helpful to users

  7. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

hp4score(data: ('SASdata', <class 'str'>) = None, id: str = None, importance: str = None, performance: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HP4SCORE procedure

Documentation link: https://go.documentation.sas.com/?docsetId=emhpprcref&docsetTarget=emhpprcref_hp4score_toc.htm&docsetVersion=14.2&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm id:

The id variable can only be a string type.

Parm importance:

The importance variable can only be a string type.

Parm performance:

The performance variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpbnet(data: ('SASdata', <class 'str'>) = None, code: str = None, freq: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, performance: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPBNET procedure

Documentation link: http://go.documentation.sas.com/?docsetId=emhpprcref&docsetVersion=14.2&docsetTarget=emhpprcref_hpbnet_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm performance:

The performance variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpclus(data: ('SASdata', <class 'str'>) = None, freq: str = None, id: (<class 'str'>, <class 'list'>) = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPCLUS procedure

Documentation link: https://go.documentation.sas.com/?docsetId=emhpprcref&docsetTarget=emhpprcref_hpclus_toc.htm&docsetVersion=14.2&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm score:

The score variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpforest(data: ('SASdata', <class 'str'>) = None, freq: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, save: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPFOREST procedure

Documentation link: https://support.sas.com/documentation/solutions/miner/emhp/14.1/emhpprcref.pdf

Parameters:

data – SASdata object or string. This parameter is required.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm save:

The save variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpneural(data: ('SASdata', <class 'str'>) = None, architecture: str = None, code: str = None, hidden: (<class 'str'>, <class 'int'>) = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, partition: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, train: (<class 'str'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPNEURAL procedure

Documentation link: https://support.sas.com/documentation/solutions/miner/emhp/14.1/emhpprcref.pdf

Parameters:

data – SASdata object or string. This parameter is required.

Parm architecture:

The architecture variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm hidden:

The hidden variable can only be a string type. This statement is required if there is a Train statement and the architecture is not logistic.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm partition:

The partition variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm train:

The train variable can be a string or dict type. This parameter is required

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

treeboost(data: ('SASdata', <class 'str'>) = None, assess: str = None, code: str = None, freq: str = None, importance: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, performance: str = None, save: (<class 'str'>, <class 'bool'>) = True, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, subseries: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TREEBOOST procedure

Documentation link: https://support.sas.com/documentation/solutions/miner/emhp/14.1/emhpprcref.pdf

Parameters:

data – SASdata object or string. This parameter is required.

Parm assess:

The assess variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm importance:

The importance variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm performance:

The performance variable can only be a string type.

Parm save:

The save variable can be a string or boolean type. The default is True to create common output datasets

Parm score:

The score variable can only be a string type.

Parm subseries:

The subseries variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable. This parameter is required

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

Statistics

class saspy.sasstat.SASstat(session, *args, **kwargs)

This class is for SAS/STAT procedures to be called as python3 objects and use SAS as the computational engine

This class and all the useful work in this package require a licensed version of SAS.

  1. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc).

  2. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc.

  3. Create a set of valid statements. Here is an example:

    lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}
    

    The case and order of the items will be formated.

  4. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  5. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  6. Add a link to the SAS documentation plus any additional details will be helpful to users

  7. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

factor(data: ('SASdata', <class 'str'>) = None, by: (<class 'str'>, <class 'list'>) = None, freq: str = None, partial: str = None, pathdiagram: str = None, priors: str = None, var: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the FACTOR procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_factor_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required..

Parm by:

The by variable can be a string or list type.

Parm freq:

The freq variable can only be a string type.

Parm partial:

The partial variable can only be a string type.

Parm pathdiagram:

The pathdiagram variable can only be a string type.

Parm priors:

The priors variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

glm(data: ('SASdata', <class 'str'>) = None, absorb: str = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, contrast: str = None, estimate: str = None, freq: str = None, id: str = None, lsmeans: str = None, manova: str = None, means: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, random: str = None, repeated: str = None, test: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the GLM procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_glm_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm absorb:

The absorb variable can only be a string type.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm contrast:

The contrast variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm lsmeans:

The lsmeans variable can only be a string type.

Parm manova:

The manova variable can only be a string type.

Parm means:

The means variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm random:

The random variable can only be a string type.

Parm repeated:

The repeated variable can only be a string type.

Parm test:

The test variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hplogistic(data: ('SASdata', <class 'str'>) = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, code: str = None, freq: str = None, id: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, selection: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPLOGISTIC procedure

Documentation link. https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=stathpug&docsetTarget=stathpug_hplogistic_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm selection:

The selection variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpreg(data: ('SASdata', <class 'str'>) = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, code: str = None, freq: str = None, id: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, performance: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, selection: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPREG procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=stathpug&docsetTarget=stathpug_hpreg_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm performance:

The performance variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm selection:

The selection variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

hpsplit(data: ('SASdata', <class 'str'>) = None, cls: (<class 'str'>, <class 'list'>) = None, code: str = None, grow: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, performance: str = None, prune: str = None, rules: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPSPLIT procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=stathpug&docsetTarget=stathpug_hpsplit_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm code:

The code variable can only be a string type.

Parm grow:

The grow variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm performance:

The performance variable can only be a string type.

Parm prune:

The prune variable can only be a string type.

Parm rules:

The rules variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

logistic(data: ('SASdata', <class 'str'>) = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, contrast: str = None, effect: str = None, effectplot: str = None, estimate: str = None, exact: str = None, freq: str = None, lsmeans: str = None, oddsratio: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, roc: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, slice: str = None, store: str = None, strata: str = None, units: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the LOGISTIC procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_logistic_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm absorb:

The absorb variable can only be a string type.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm contrast:

The contrast variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm lsmeans:

The lsmeans variable can only be a string type.

Parm manova:

The manova variable can only be a string type.

Parm means:

The means variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm random:

The random variable can only be a string type.

Parm repeated:

The repeated variable can only be a string type.

Parm test:

The test variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

mi(data: ('SASdata', <class 'str'>) = None, by: (<class 'str'>, <class 'list'>) = None, cls: (<class 'str'>, <class 'list'>) = None, em: str = None, fcs: str = None, freq: str = None, mcmc: str = None, mnar: str = None, monotone: str = None, transform: str = None, var: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the MI procedure.

Documentation link: https://go.documentation.sas.com/doc/en/statug/15.2/statug_mi_toc.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can be a string or list type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm em:

The em variable can only be a string type.

Parm fcs:

The fcs variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm mcmc:

The mcmc variable can only be a string type.

Parm mnar:

The mnar variable can only be a string type.

Parm monotone:

The monotone variable can only be a string type.

Parm transform:

The transform variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

mixed(data: ('SASdata', <class 'str'>) = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, code: str = None, contrast: str = None, estimate: str = None, id: str = None, lsmeans: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, random: str = None, repeated: str = None, slice: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the MIXED procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_mixed_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm code:

The code variable can only be a string type.

Parm contrast:

The contrast variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm id:

The id variable can only be a string type.

Parm lsmeans:

The lsmeans variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm random:

The random variable can only be a string type.

Parm repeated:

The repeated variable can only be a string type.

Parm slice:

The slice variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

phreg(data: ('SASdata', <class 'str'>) = None, assess: str = None, bayes: str = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, contrast: str = None, effect: str = None, estimate: str = None, freq: str = None, hazardratio: str = None, id: str = None, lsmeans: str = None, lsmestimate: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, random: str = None, roc: str = None, slice: str = None, store: str = None, strata: str = None, test: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the PHREG procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_phreg_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm assess:

The assess variable can only be a string type.

Parm bayes:

The bayes variable can only be a string type.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm contrast:

The contrast variable can only be a string type.

Parm effect:

The effect variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm freq:

The freq variable can only be a string type.

Parm hazardratio:

The hazardratio variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm lsmeans:

The lsmeans variable can only be a string type.

Parm lsmestimate:

The lsmestimate variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm random:

The random variable can only be a string type.

Parm roc:

The roc variable can only be a string type.

Parm slice:

The slice variable can only be a string type.

Parm store:

The store variable can only be a string type.

Parm strata:

The strata variable can only be a string type.

Parm test:

The test variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

reg(data: ('SASdata', <class 'str'>) = None, add: str = None, by: str = None, code: str = None, id: str = None, lsmeans: str = None, model: str = None, out: (<class 'str'>, <class 'bool'>, 'SASdata') = None, random: str = None, repeated: str = None, slice: str = None, test: str = None, var: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the REG procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_reg_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm add:

The add variable can only be a string type.

Parm by:

The by variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm lsmeans:

The lsmeans variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm out:

The out variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm random:

The random variable can only be a string type.

Parm repeated:

The repeated variable can only be a string type.

Parm slice:

The slice variable can only be a string type.

Parm test:

The test variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

tpspline(data: ('SASdata', <class 'str'>) = None, by: str = None, freq: str = None, id: str = None, model: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TPSPLINE procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_tpspline_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm score:

The score variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

ttest(data: ('SASdata', <class 'str'>) = None, by: str = None, cls: (<class 'str'>, <class 'list'>) = None, freq: str = None, paired: str = None, var: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TTEST procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_ttest_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm freq:

The freq variable can only be a string type.

Parm paired:

The paired variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

Econometic and Time Series

class saspy.sasets.SASets(session, *args, **kwargs)

This class is for SAS/ETS procedures to be called as python3 objects and use SAS as the computational engine

This class and all the useful work in this package require a licensed version of SAS.

  1. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc).

  2. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc.

  3. Create a set of valid statements. Here is an example:

    lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}
    

    The case and order of the items will be formated.

  4. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  5. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  6. Add a link to the SAS documentation plus any additional details will be helpful to users

  7. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

arima(data: ('SASdata', <class 'str'>) = None, by: str = None, estimate: str = None, forecast: str = None, identify: str = None, out: (<class 'str'>, 'SASdata') = None, outlier: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the ARIMA procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_arima_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm forecast:

The forecast variable can only be a string type.

Parm identify:

The identify variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm outlier:

The outlier variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

autoreg(data: ('SASdata', <class 'str'>) = None, by: (<class 'str'>, <class 'list'>) = None, cls: (<class 'str'>, <class 'list'>) = None, hetero: str = None, model: str = None, nloptions: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, restrict: str = None, test: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the AUTOREG procedure

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can be a string or list type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm hetero:

The hetero variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm nloptions:

The nloptions variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm restrict:

The restrict variable can only be a string type.

Parm test:

The test variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

esm(data: ('SASdata', <class 'str'>) = None, by: str = None, forecast: str = None, id: str = None, out: (<class 'str'>, 'SASdata') = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the ESM procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_esm_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm forecast:

The forecast variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

expand(data: ('SASdata', <class 'str'>) = None, by: (<class 'str'>, <class 'list'>) = None, convert: str = None, id: (<class 'str'>, <class 'list'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the EXPAND procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=etsug&docsetTarget=etsug_expand_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can be a string or list type.

Parm convert:

The convert variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

timedata(data: ('SASdata', <class 'str'>) = None, by: str = None, fcmport: str = None, id: str = None, out: (<class 'str'>, 'SASdata') = None, outarrays: str = None, outscalars: str = None, prog_stmts: str = None, var: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TIMEDATA procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_timedata_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm fcmport:

The fcmport variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm outarrays:

The outarrays variable can only be a string type.

Parm outscalars:

The outscalars variable can only be a string type.

Parm prog_stmts:

The prog_stmts variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

timeid(data: ('SASdata', <class 'str'>) = None, by: str = None, id: str = None, out: (<class 'str'>, 'SASdata') = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TIMEID procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_timeid_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

timeseries(data: ('SASdata', <class 'str'>) = None, by: str = None, corr: str = None, crosscorr: str = None, crossvar: str = None, decomp: str = None, id: str = None, out: (<class 'str'>, 'SASdata') = None, season: str = None, trend: str = None, var: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TIMESERIES procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_timeseries_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm corr:

The corr variable can only be a string type.

Parm crosscorr:

The crosscorr variable can only be a string type.

Parm crossvar:

The crossvar variable can only be a string type.

Parm decomp:

The decomp variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm season:

The season variable can only be a string type.

Parm trend:

The trend variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

ucm(data: ('SASdata', <class 'str'>) = None, autoreg: str = None, blockseason: str = None, by: str = None, cycle: str = None, deplag: str = None, estimate: (<class 'str'>, <class 'bool'>) = None, forecast: str = None, id: str = None, irregular: (<class 'str'>, <class 'bool'>) = None, level: (<class 'str'>, <class 'bool'>) = None, model: str = None, nloptions: str = None, out: (<class 'str'>, 'SASdata') = None, outlier: str = None, performance: str = None, randomreg: str = None, season: str = None, slope: (<class 'str'>, <class 'bool'>) = None, splinereg: str = None, splineseason: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the UCM procedure

Documentation link: http://support.sas.com/documentation/cdl//en/etsug/68148/HTML/default/viewer.htm#etsug_ucm_syntax.htm

Parameters:

data – SASdata object or string. This parameter is required.

Parm autoreg:

The autoreg variable can only be a string type.

Parm blockseason:

The blockseason variable can only be a string type.

Parm by:

The by variable can only be a string type.

Parm cycle:

The cycle variable can only be a string type.

Parm deplag:

The deplag variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm forecast:

The forecast variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm irregular:

The irregular variable can be a string or boolean type.

Parm level:

The level variable can be a string or boolean type.

Parm model:

The model variable can only be a string type.

Parm nloptions:

The nloptions variable can only be a string type.

Parm out:

The out variable can be a string or SASdata type.

Parm outlier:

The outlier variable can only be a string type.

Parm performance:

The performance variable can only be a string type.

Parm randomreg:

The randomreg variable can only be a string type.

Parm season:

The season variable can only be a string type.

Parm slope:

The slope variable can be a string or boolean type.

Parm splinereg:

The splinereg variable can only be a string type.

Parm splineseason:

The splineseason variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

varmax(data: ('SASdata', <class 'str'>) = None, bound: str = None, by: (<class 'str'>, <class 'list'>) = None, causal: str = None, cointeg: str = None, condfore: str = None, garch: str = None, id: (<class 'str'>, <class 'list'>) = None, initial: str = None, model: str = None, nloptions: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, restrict: str = None, test: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the VARMAX procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=etsug&docsetTarget=etsug_varmax_syntax.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm bound:

The adjust variable can only be a string type.

Parm by:

The by variable can be a string or list type.

Parm casual:

The check variable can only be a string type.

Parm cointeg:

The cointeg variable can only be a string type.

Parm condfore:

The condfore variable can only be a string type.

Parm garch:

The garch variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm initial:

The initial variable can only be a string type.

Parm model:

The model variable can only be a string.

Parm nloptions:

The nloptions variable can only be a string.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm restrict:

The restrict variable can only be a string.

Parm test:

The test variable can only be a string.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

x11(data: ('SASdata', <class 'str'>) = None, arima: str = None, by: (<class 'str'>, <class 'list'>) = None, id: (<class 'str'>, <class 'list'>) = None, macurves: str = None, monthly: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, pdweights: str = None, quarterly: str = None, sspan: str = None, tables: str = None, var: str = None, procopts: (<class 'str'>, <class 'list'>) = None, stmtpassthrough: (<class 'str'>, <class 'list'>) = None, **kwargs: dict) SASresults

Python method to call the X11 procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=etsug&docsetTarget=etsug_x11_syntax.htm&locale=en

Either the MONTHLY or QUARTERLY statement must be specified, depending on the type of time series data you have. The PDWEIGHTS and MACURVES statements can be used only with the MONTHLY statement. The TABLES statement controls the printing of tables, while the OUTPUT statement controls the creation of the OUT= data set.

Parameters:

data – SASdata object or string. This parameter is required.

Parm arima:

The arima variable can only be a string type.

Parm by:

The by variable can be a string or list type.

Parm id:

The id variable can be a string or list type.

Parm macurves:

The macurves variable can only be a string type.

Parm monthly:

The monthly variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm pdweights:

The pdweights variable can only be a string type.

Parm quarterly:

The quarterly variable can only be a string type.

Parm sspan:

The sspan variable can only be a string type.

Parm tables:

The tables variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

x12(data: ('SASdata', <class 'str'>) = None, adjust: str = None, arima: str = None, automdl: str = None, by: (<class 'str'>, <class 'list'>) = None, check: str = None, estimate: (<class 'str'>, <class 'bool'>) = True, event: str = None, forecast: str = None, id: (<class 'str'>, <class 'list'>) = None, identify: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, outlier: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, pickmdl: str = None, regression: str = None, seatsdecomp: str = None, tables: str = None, transform: str = None, userdefined: str = None, var: str = None, x11: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the X12 procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=etsug&docsetTarget=etsug_x12_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm adjust:

The adjust variable can only be a string type.

Parm arima:

The arima variable can only be a string type.

Parm automdl:

The automdl variable can only be a string type.

Parm by:

The by variable can be a string or list type.

Parm check:

The check variable can only be a string type.

Parm estimate:

The estimate variable is a string, or list of strings for procs that support multiple estimate statements.

Parm event:

The event variable can only be a string type.

Parm forecast:

The forecast variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm identify:

The identify variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm outlier:

The outlier variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm pickmdl:

The pickmdl variable can only be a string type.

Parm regression:

The regression variable can only be a string type.

Parm seatsdecomp:

The seatsdecomp variable can only be a string type.

Parm tables:

The tables variable can only be a string type.

Parm transform:

The transform variable can only be a string type.

Parm userdefined:

The userdefined variable can only be a string type.

Parm var:

The var variable can only be a string type.

Parm x11:

The x11 variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

Quality Control

class saspy.sasqc.SASqc(session, *args, **kwargs)

This class is for SAS/QC procedures to be called as python3 objects and use SAS as the computational engine This class and all the useful work in this package require a licensed version of SAS.

  1. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc).

  2. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc.

  3. Create a set of valid statements. Here is an example:

    lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}
    

    The case and order of the items will be formated.

  4. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  5. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  6. Add a link to the SAS documentation plus any additional details will be helpful to users

  7. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

capability(data: ('SASdata', <class 'str'>) = None, by: str = None, cdfplot: str = None, comphist: str = None, freq: str = None, histogram: str = None, id: str = None, inset: str = None, intervals: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, ppplot: str = None, probplot: str = None, qqplot: str = None, spec: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the CAPABILITY procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=qcug&docsetTarget=qcug_capability_sect001.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm by:

The by variable can only be a string type.

Parm cdfplot:

The cdfplot variable can only be a string type.

Parm comphist:

The comphist variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm histogram:

The histogram variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm inset:

The inset variable can only be a string type.

Parm intervals:

The intervals variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm ppplot:

The ppplot variable can only be a string type.

Parm probplot:

The probplot variable can only be a string type.

Parm qqplot:

The qqplot variable can only be a string type.

Parm spec:

The spec variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

cusum(data: ('SASdata', <class 'str'>) = None, by: str = None, inset: str = None, xchart: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the CUSUM procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=qcug&docsetTarget=qcug_cusum_toc.htm&locale=en :param data: SASdata object or string. This parameter is required. :parm by: The by variable can only be a string type. :parm inset: The inset variable can only be a string type. :parm xchart: The xchart variable can only be a string type. :parm procopts: The procopts variable is a generic option available for advanced use. It can only be a string type. :parm stmtpassthrough: The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type. :return: SAS Result Object

macontrol(data: ('SASdata', <class 'str'>) = None, ewmachart: str = None, machart: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the MACONTROL procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=qcug&docsetTarget=qcug_macontrol_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm ewmachart:

The ewmachart variable can only be a string type.

Parm machart:

The machart variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

shewhart(data: ('SASdata', <class 'str'>) = None, boxchart: str = None, cchart: str = None, irchart: str = None, mchart: str = None, mrchart: str = None, npchart: str = None, pchart: str = None, rchart: str = None, schart: str = None, uchart: str = None, xrchart: str = None, xschart: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the SHEWHART procedure

Documentation link: https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=qcug&docsetTarget=qcug_shewhart_toc.htm&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm boxchart:

The boxchart variable can only be a string type.

Parm cchart:

The cchart variable can only be a string type.

Parm irchart:

The irchart variable can only be a string type.

Parm mchart:

The mchart variable can only be a string type.

Parm mrchart:

The mrchart variable can only be a string type.

Parm npchart:

The npchart variable can only be a string type.

Parm pchart:

The pchart variable can only be a string type.

Parm rchart:

The rchart variable can only be a string type.

Parm schart:

The schart variable can only be a string type.

Parm uchart:

The uchart variable can only be a string type.

Parm xrchart:

The xrchart variable can only be a string type.

Parm xschart:

The xschart variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

SAS Viya VDMML

class saspy.sasViyaML.SASViyaML(session, *args, **kwargs)

This class is for SAS Viya procedures to be called as python3 objects and use SAS as the computational engine This class and all the useful work in this package require a licensed version of SAS. #. Identify the product of the procedure (SAS/STAT, SAS/ETS, SAS Enterprise Miner, etc). #. Find the corresponding file in saspy sasstat.py, sasets.py, sasml.py, etc. #. Create a set of valid statements. Here is an example:

lset = {'ARIMA', 'BY', 'ID', 'MACURVES', 'MONTHLY', 'OUTPUT', 'VAR'}

The case and order of the items will be formated.

  1. Call the doc_convert method to generate then method call as well as the docstring markup

    import saspy
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['method_stmt'])
    print(saspy.sasdecorator.procDecorator.doc_convert(lset, 'x11')['markup_stmt'])
    

    The doc_convert method takes two arguments: a list of the valid statements and the proc name. It returns a dictionary with two keys, method_stmt and markup_stmt. These outputs can be copied into the appropriate product file.

  2. Add the proc decorator to the new method.

    The decorator should be on the line above the method declaration. The decorator takes one argument, the required statements for the procedure. If there are no required statements than an empty list {} should be passed. Here are two examples one with no required arguments:

    @procDecorator.proc_decorator({})
    def esm(self, data: ['SASdata', str] = None, ...
    

    And one with required arguments:

    @procDecorator.proc_decorator({'model'})
    def mixed(self, data: ['SASdata', str] = None, ...
    
  3. Add a link to the SAS documentation plus any additional details will be helpful to users

  4. Write at least one test to exercise the procedures and include it in the appropriate testing file.

If you have questions, please open an issue in the GitHub repo and the maintainers will be happy to help.

bnet(data: ('SASdata', <class 'str'>) = None, autotune: str = None, code: str = None, freq: str = None, id: (<class 'str'>, <class 'list'>) = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, savestate: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, stmtpassthrough: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, **kwargs: dict) SASresults

Python method to call the BNET procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm savesstate:

The savesstate variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

factmac(data: ('SASdata', <class 'str'>) = None, autotune: str = None, code: str = None, display: str = None, displayout: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, savestate: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the FACTMAC procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_factmac_syntax.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm savestate:

The savestate variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

fastknn(data: ('SASdata', <class 'str'>) = None, display: str = None, displayout: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the FASTKNN procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_fastknn_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

forest(data: ('SASdata', <class 'str'>) = None, autotune: str = None, code: str = None, crossvalidation: str = None, grow: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, savestate: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, viicode: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the FOREST procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_forest_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm crossvalidation:

The crossvalidation variable can only be a string type.

Parm grow:

The grow variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm savestate:

The savestate variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm viicode:

The viicode variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

gmm(data: ('SASdata', <class 'str'>) = None, display: str = None, displayout: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, savestate: str = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the GMM procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm savestate:

The savestate variable can only be a string type.

Parm score:

The score variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

gradboost(data: ('SASdata', <class 'str'>) = None, autotune: str = None, code: str = None, crossvalidation: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, savestate: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, transferlearn: str = None, viicode: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPCLUS procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_gradboost_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm crossvalidation:

The crossvalidation variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm savestate:

The savestate variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm transferlearn:

The transferlearn variable can only be a string type.

Parm viicode:

The viicode variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

gvarclus(data: ('SASdata', <class 'str'>) = None, display: str = None, displayout: str = None, freq: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the GVARCLUS procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

kclus(data: ('SASdata', <class 'str'>) = None, code: str = None, display: str = None, displayout: str = None, freq: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, score: (<class 'str'>, <class 'bool'>, 'SASdata') = True, procopts: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, stmtpassthrough: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, **kwargs: dict) SASresults

Python method to call the KCLUS procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm code:

The code variable can only be a string type.

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm score:

The score variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

nnet(data: ('SASdata', <class 'str'>) = None, architecture: str = None, autotune: str = None, code: str = None, crossvalidation: str = None, hidden: (<class 'str'>, <class 'int'>) = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, optimization: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, train: (<class 'str'>, <class 'dict'>) = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the HPNEURAL procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_nnet_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm architecture:

The architecture variable can only be a string type.

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm crossvalidation:

The crossvalidation variable can only be a string type.

Parm hidden:

The hidden variable can only be a string type. This statement is required if there is a Train statement and the architecture is not GLIM.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm optimization:

The optimization variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm train:

The train variable can be a string or dict type. This parameter is required

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

rpca(data: ('SASdata', <class 'str'>) = None, anomalydetection: str = None, code: str = None, display: str = None, displayout: str = None, id: (<class 'str'>, <class 'list'>) = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, outdecomp: str = None, savestate: str = None, svd: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the RPCA procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm anomalydetection:

The anomalydetection variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm display:

The display variable can only be a string type.

Parm displayout:

The displayout variable can only be a string type.

Parm id:

The id variable can be a string or list type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm outdecomp:

The outdecomp variable can only be a string type.

Parm savestate:

The savestate variable can only be a string type.

Parm svd:

The svd variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

svdd(data: ('SASdata', <class 'str'>) = None, code: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, kernel: str = None, savestate: str = None, solver: str = None, weight: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the SVDD procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_svdd_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm code:

The code variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm kernel:

The kernel variable can only be a string type.

Parm savestate:

The savestate variable can only be a string type.

Parm solver:

The solver variable can only be a string type.

Parm weight:

The weight variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

svmachine(data: ('SASdata', <class 'str'>) = None, autotune: str = None, code: str = None, id: str = None, input: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, kernel: str = None, output: (<class 'str'>, <class 'bool'>, 'SASdata') = None, partition: str = None, savestate: str = None, solver: str = None, target: (<class 'str'>, <class 'list'>, <class 'dict'>) = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the SVMACHINE procedure

Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_svmachine_toc.htm&docsetVersion=8.3&locale=en

Parameters:

data – SASdata object or string. This parameter is required.

Parm autotune:

The autotune variable can only be a string type.

Parm code:

The code variable can only be a string type.

Parm id:

The id variable can only be a string type.

Parm input:

The input variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm kernel:

The kernel variable can only be a string type.

Parm output:

The output variable can be a string, boolean or SASdata type. The member name for a boolean is “_output”.

Parm partition:

The partition variable can only be a string type.

Parm savestate:

The savestate variable can only be a string type.

Parm solver:

The solver variable can only be a string type.

Parm target:

The target variable can be a string, list or dict type. It refers to the dependent, y, or label variable.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

treesplit(data: ('SASdata', <class 'str'>) = None, autotune: str = None, cls: (<class 'str'>, <class 'list'>) = None, code: str = None, freq: str = None, grow: str = None, model: str = None, outputprune: str = None, partition: str = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) SASresults

Python method to call the TREESPLIT procedure.

Documentation link:

Parameters:

data – SASdata object or string. This parameter is required..

Parm autotune:

The autotune variable can only be a string type.

Parm cls:

The cls variable can be a string or list type. It refers to the categorical, or nominal variables.

Parm code:

The code variable can only be a string type.

Parm freq:

The freq variable can only be a string type.

Parm grow:

The grow variable can only be a string type.

Parm model:

The model variable can only be a string type.

Parm outputprune:

The outputprune variable can only be a string type.

Parm partition:

The partition variable can only be a string type.

Parm procopts:

The procopts variable is a generic option available for advanced use. It can only be a string type.

Parm stmtpassthrough:

The stmtpassthrough variable is a generic option available for advanced use. It can only be a string type.

Returns:

SAS Result Object

SASPy Scripts

run_sas.py

This user contributed script if for executing a .sas file and writing the LOG and LST to files, much like running a .sas file from SAS in batch mode.

Usage: run_sas.py [-h] [-s SAS_FNAME] [-l LOG_FNAME] [-o LST_FNAME]

[-r RESULTS_FORMAT] [-c CFGNAME]

Required argument:
-s SAS_FNAME, --sas_fname SAS_FNAME

Name of the SAS file to be executed.

Optional arguments:
-h, --help

show this help message and exit

-l LOG_FNAME, --log_fname LOG_FNAME

Name of the output LOG file name. If not specified then it is the same as the sas_fname with .sas removed and .log added.

-o LST_FNAME, --lst_fname LST_FNAME

Name of the output LST file. If not specified then it is the same as the sas_fname with .sas removed and .lst/.html added depending on the results format.

-r RESULTS_FORMAT, --results_format RESULTS_FORMAT

Results format for sas_session.submit(). It may be either TEXT or HTML. If not specified it is TEXT by default. It is case incesensitive.

-c CFGNAME, --cfgname CFGNAME

Name of the Configuration Definition to use for the SASsession. If not specified then just saspy.SASsession() is executed.

Examples:

./run_sas.py -s example_1.sas
./run_sas.py -s example_1.sas -l out1.log -o out1.lst
./run_sas.py -s example_1.sas -r TEXT
./run_sas.py -s example_1.sas -r HTML
./run_sas.py -s example_1.sas -r htMl -l out2.log -o out2.html
./run_sas.py -s example_1.sas -r teXt -l out3.log -o out3.lst
./run_sas.py -s /home/a/b/c/example_1.sas
./run_sas.py -s example_1.sas -r text -l out4.log -o out4.lst -c ssh