API Reference

saspy.isnotebook()

SAS Session Object

class saspy.SASsession(**kwargs)

Bases: object

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/install.html#configuration These are generally defined in the sascfg_personal.py file as opposed to being specified on the SASsession() invocation.

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 Data Frames.
  • autoexec – A string of SAS code that will be submitted upon establishing a connection
Returns:

‘SASsession’

Return type:

‘SASsession’

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.

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
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()

This method returns the list of currently assigned librefs

dataframe2sasdata(df: pandas.core.frame.DataFrame, table: str = '_df', libref: str = '', results: str = '', keep_outer_quotes: bool = False) → saspy.sasdata.SASdata

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

Parameters:
  • df – Pandas Data Frame 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
  • keep_outer_quotes – the defualt is for SAS to strip outer quotes from delimitted data. This lets you keep them
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: pandas.core.frame.DataFrame, table: str = '_df', libref: str = '', results: str = '', keep_outer_quotes: bool = False) → saspy.sasdata.SASdata

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

Parameters:
  • dfpandas.DataFrame Pandas Data Frame 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
  • keep_outer_quotes – the defualt is for SAS to strip outer quotes from delimitted data. This lets you keep them
Returns:

SASdata object

dirlist(path)

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

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_info(filepath, results: str = 'dict', fileref: str = '_spfinfo')

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

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

list_tables(libref, results: str = '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: dict = None) → saspy.sasdata.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: dict = None) → saspy.sasdata.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 numbers - either string or int
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"'
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight'
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight']
     'obs'      :  10
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
Returns:

SASdata object

sasdata2dataframe(table: str, libref: str = '', dsopts: dict = None, method: str = 'MEMORY', **kwargs) → pandas.core.frame.DataFrame

This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame

Parameters:
  • 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

    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 numbers - either string or int
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"'
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight'
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight']
     'obs'      :  10
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
  • method – defaults to MEMORY; the original method. CSV is the other choice which uses an intermediary csv file; faster for large data
  • kwargs – dictionary
Returns:

Pandas data frame

sasets() → saspy.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: str = '', options: str = ' ', prompt: dict = None) → str
Parameters:
  • libref – the libref to be assigned
  • engine – the engine name used to access the SAS Library (engine defaults to BASE, per SAS)
  • path – path to the library (for engines that take a path parameter)
  • options – other engine or engine supervisor options
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() → saspy.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() → saspy.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() → saspy.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() → saspy.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() → saspy.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: dict = None, method: str = 'MEMORY', **kwargs) → pandas.core.frame.DataFrame

This is an alias for ‘sasdata2dataframe’. Why type all that? SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame

Parameters:
  • 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

    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 numbers - either string or int
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"'
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight'
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight']
     'obs'      :  10
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
  • method – defaults to MEMORY; the original method. CSV is the other choice which uses an intermediary csv file; faster for large data
  • kwargs – dictionary
Returns:

Pandas data frame

sd2df_CSV(table: str, libref: str = '', dsopts: dict = None, tempfile: str = None, tempkeep: bool = False, **kwargs) → pandas.core.frame.DataFrame

This is an alias for ‘sasdata2dataframe’ specifying method=’CSV’. Why type all that? SASdata object that refers to the Sas Data Set you want to export to a Pandas Data Frame

Parameters:
  • 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

    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 numbers - either string or int
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"'
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight'
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight']
     'obs'      :  10
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
  • tempfile – [optional] an OS path for a file to use for the local CSV file; default it a temporary file that’s cleaned up
  • tempkeep – if you specify your own file to use with tempfile=, this controls whether it’s cleaned up after using it
  • kwargs – dictionary
Returns:

Pandas data frame

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
Return type:bool
Returns: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
submit(code: str, results: str = '', prompt: dict = None) → dict

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

  • code - the SAS statements you want to execute

  • results - format of results, HTLML and TEXT is the alternative

  • prompt - dict of names: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}
                 )
    

    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()

i.e,: results = sas.submit(“data a; x=1; run; proc print;run’)
print(results[‘LOG’]) HTML(results[‘LST’])
symget(name)
Parameters:name

name of the macro varable to set:

  • name is a character
symput(name, value)
Parameters:
  • name – name of the macro varable to set:
  • value

    python variable to use for the value to assign to the macro variable:

    • name is a character
    • value is a variable that can be resolved to a string
teach_me_SAS(nosub: bool)
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.
write_csv(file: str, table: str, libref: str = '', dsopts: dict = None, opts: 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)
  • opts

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

    • 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
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"'
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight'
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight']
     'obs'      :  10
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
Returns:

SAS log

SAS Data Object

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

Bases: object

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
    • first obs is a numbers - either string or int
    • format is a string or dictionary { var: format }
    {'where'    : 'msrp < 20000 and make = "Ford"',
     'keep'     : 'msrp enginesize Cylinders Horsepower Weight',
     'drop'     : ['msrp', 'enginesize', 'Cylinders', 'Horsepower', 'Weight'],
     'obs'      :  10,
     'firstobs' : '12'
     'format'  : {'money': 'dollar10', 'time': 'tod5.'}
    }
    
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

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()

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

Returns:output
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: typing.Union[saspy.sasdata.SASdata, NoneType] = None) → saspy.sasdata.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:

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:
partition(var: str = '', fraction: float = 0.7, seed: int = 9878, kfold: int = 1, out: typing.Union[saspy.sasdata.SASdata, NoneType] = 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

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: typing.Union[saspy.sasdata.SASdata, NoneType] = None) → saspy.sasdata.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) → saspy.sasdata.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: 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)
Returns:
to_df(method: str = 'MEMORY', **kwargs) → pandas.core.frame.DataFrame

Export this SAS Data Set to a Pandas Data Frame

Parameters:
  • method – defaults to MEMORY; the original method. CSV is the other choice which uses an intermediary csv file; faster for large data
  • kwargs
Returns:

Pandas data frame

to_df_CSV(tempfile: str = None, tempkeep: bool = False, **kwargs) → pandas.core.frame.DataFrame

Export this SAS Data Set to a Pandas Data Frame via CSV file

Parameters:
  • tempfile – [optional] an OS path for a file to use for the local CSV file; default it a temporary file that’s cleaned up
  • tempkeep – if you specify your own file to use with tempfile=, this controls whether it’s cleaned up after using it
  • kwargs
Returns:

Pandas data frame

Return type:

‘pd.DataFrame’

to_frame(**kwargs) → pandas.core.frame.DataFrame

Export this SAS Data Set to a Pandas Data Frame

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

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) → saspy.sasdata.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)

Bases: object

SAS Results

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

Bases: object

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)

Bases: object

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()

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()

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()

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()

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)

Bases: object

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()

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()

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
hpcluster()

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()

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()

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()

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
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

Statistics

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

Bases: object

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()

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 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
glm()

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 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 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()

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()

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()

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()

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 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 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
mixed()

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 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 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()

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 can only be a string type.
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()

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()

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()

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)

Bases: object

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()

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 can only be a string type.
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()

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()

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()

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()

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()

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()

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()

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 can be a string or boolean type.
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()

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 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 can only be a string type.
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
x11()

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()

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 can only be a string type.
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)

Bases: object

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()

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()

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()

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()

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)

Bases: object

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.

factmac()

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()

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()

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
gradboost()

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
nnet()

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
svdd()

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()

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