def partition(self, var: str = '<STR_LIT>', fraction: float = <NUM_LIT>, seed: int = <NUM_LIT>, kfold: int = <NUM_LIT:1>,<EOL>out: '<STR_LIT>' = None, singleOut: bool = True) -> object:
<EOL>i = <NUM_LIT:1><EOL>code = '<STR_LIT>'<EOL>try:<EOL><INDENT>k = int(kfold)<EOL><DEDENT>except ValueError:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>if out is None:<EOL><INDENT>out_table = self.table<EOL>out_libref = self.libref<EOL><DEDENT>elif not isinstance(out, str):<EOL><INDENT>out_table = out.table<EOL>out_libref = out.libref<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>out_table = out.split('<STR_LIT:.>')[<NUM_LIT:1>]<EOL>out_libref = out.split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>out_table = out<EOL>out_libref = '<STR_LIT>'<EOL><DEDENT><DEDENT>while i <= k:<EOL><INDENT>if k == <NUM_LIT:1>:<EOL><INDENT>code += "<STR_LIT>" % (<EOL>self.libref, self.table, self._dsopts(), out_libref, out_table, self._dsopts(), fraction * <NUM_LIT:100>,<EOL>seed)<EOL><DEDENT>else:<EOL><INDENT>seed += <NUM_LIT:1><EOL>code += "<STR_LIT>" % (<EOL>self.libref, self.table, self._dsopts(), out_libref, out_table, self._dsopts(), fraction * <NUM_LIT:100>,<EOL>seed, i)<EOL><DEDENT>if len(var) > <NUM_LIT:0>:<EOL><INDENT>if i == <NUM_LIT:1>:<EOL><INDENT>num_string = """<STR_LIT>"""<EOL>nosub = self.sas.nosub<EOL>self.sas.nosub = False<EOL>ll = self.sas.submit(num_string.format(self.libref, self.table + self._dsopts()))<EOL>self.sas.nosub = nosub<EOL>l2 = ll['<STR_LIT>'].partition("<STR_LIT>")<EOL>l2 = l2[<NUM_LIT:2>].rpartition("<STR_LIT>")<EOL>numlist1 = l2[<NUM_LIT:0>].split("<STR_LIT:\n>")<EOL>if isinstance(var, str):<EOL><INDENT>tlist = var.split()<EOL><DEDENT>elif isinstance(var, list):<EOL><INDENT>tlist = var<EOL><DEDENT>else:<EOL><INDENT>raise SyntaxError("<STR_LIT>" % str(type(var)))<EOL><DEDENT><DEDENT>if set(numlist1).isdisjoint(tlist):<EOL><INDENT>if isinstance(var, str):<EOL><INDENT>code += "<STR_LIT>" % var<EOL><DEDENT>else:<EOL><INDENT>code += "<STR_LIT>" % "<STR_LIT:U+0020>".join(var)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>varlist = [x for x in numlist1 if x not in tlist]<EOL>varlist.extend(["<STR_LIT>" % j for j in range(<NUM_LIT:1>, i) if k > <NUM_LIT:1> and i > <NUM_LIT:1>])<EOL>code += "<STR_LIT>" % (var, var, "<STR_LIT:U+0020>".join(varlist))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>code += "<STR_LIT>"<EOL><DEDENT>code += "<STR_LIT>"<EOL>i += <NUM_LIT:1><EOL><DEDENT>split_code = '<STR_LIT>'<EOL>if not singleOut:<EOL><INDENT>split_code += '<STR_LIT>'<EOL>for j in range(<NUM_LIT:1>, k + <NUM_LIT:1>):<EOL><INDENT>split_code += "<STR_LIT>" % (out_libref, out_table, j)<EOL>split_code += "<STR_LIT>" % (out_libref, out_table, j)<EOL><DEDENT>split_code += '<STR_LIT>' % (out_libref, out_table)<EOL>for z in range(<NUM_LIT:1>, k + <NUM_LIT:1>):<EOL><INDENT>split_code += "<STR_LIT>" % (z, out_libref, out_table, z)<EOL>split_code += "<STR_LIT>" % (out_libref, out_table, z)<EOL><DEDENT>split_code += '<STR_LIT>'<EOL><DEDENT>runcode = True<EOL>if self.sas.nosub:<EOL><INDENT>print(code + '<STR_LIT>' + split_code)<EOL>runcode = False<EOL><DEDENT>ll = self._is_valid()<EOL>if ll:<EOL><INDENT>runcode = False<EOL><DEDENT>if runcode:<EOL><INDENT>ll = self.sas.submit(code + split_code, "<STR_LIT:text>")<EOL>elog = []<EOL>for line in ll['<STR_LIT>'].splitlines():<EOL><INDENT>if line.startswith('<STR_LIT>'):<EOL><INDENT>elog.append(line)<EOL><DEDENT><DEDENT>if len(elog):<EOL><INDENT>raise RuntimeError("<STR_LIT:\n>".join(elog))<EOL><DEDENT>if not singleOut:<EOL><INDENT>outTableList = []<EOL>if k == <NUM_LIT:1>:<EOL><INDENT>return (self.sas.sasdata(out_table + str(k) + "<STR_LIT>", out_libref, dsopts=self._dsopts()),<EOL>self.sas.sasdata(out_table + str(k) + "<STR_LIT>", out_libref, dsopts=self._dsopts()))<EOL><DEDENT>for j in range(<NUM_LIT:1>, k + <NUM_LIT:1>):<EOL><INDENT>outTableList.append((self.sas.sasdata(out_table + str(j) + "<STR_LIT>", out_libref, dsopts=self._dsopts()),<EOL>self.sas.sasdata(out_table + str(j) + "<STR_LIT>", out_libref, dsopts=self._dsopts())))<EOL><DEDENT>return outTableList<EOL><DEDENT>if out:<EOL><INDENT>if not isinstance(out, str):<EOL><INDENT>return out<EOL><DEDENT>else:<EOL><INDENT>return self.sas.sasdata(out_table, out_libref, self.results)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return self<EOL><DEDENT><DEDENT>
Partition a sas data object using SRS sampling or if a variable is specified then
stratifying with respect to that variable

:param var: variable(s) for stratification. If multiple then space delimited list
:param fraction: fraction to split
:param seed: random seed
:param kfold: number of k folds
:param out: the SAS data object
:param singleOut: boolean to return single table or seperate tables
:return: Tuples or SAS data object