def sasdata2dataframe(self, table: str, libref: str ='<STR_LIT>', dsopts: dict = None, rowsep: str = '<STR_LIT>', colsep: str = '<STR_LIT>', **kwargs) -> '<STR_LIT>':
dsopts = dsopts if dsopts is not None else {}<EOL>method = kwargs.pop('<STR_LIT>', None)<EOL>if method and method.lower() == '<STR_LIT>':<EOL><INDENT>return self.sasdata2dataframeCSV(table, libref, dsopts, **kwargs)<EOL><DEDENT>port =  kwargs.get('<STR_LIT:port>', <NUM_LIT:0>)<EOL>if port==<NUM_LIT:0> and self.sascfg.tunnel:<EOL><INDENT>port = self.sascfg.tunnel<EOL><DEDENT>datar = "<STR_LIT>"<EOL>if libref:<EOL><INDENT>tabname = libref+"<STR_LIT:.>"+table<EOL><DEDENT>else:<EOL><INDENT>tabname = table<EOL><DEDENT>code  = "<STR_LIT>"+tabname+self._sb._dsopts(dsopts)+"<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>code += "<STR_LIT>"<EOL>ll = self.submit(code, "<STR_LIT:text>")<EOL>l2 = ll['<STR_LIT>'].rpartition("<STR_LIT>")<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT:\n>")<EOL>lrecl = int(l2[<NUM_LIT:0>])<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT>")<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT:\n>")<EOL>nvars = int(l2[<NUM_LIT:0>])<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT:\n>")<EOL>varlist = l2[<NUM_LIT:2>].split("<STR_LIT:\n>", nvars)<EOL>del varlist[nvars]<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT>")<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT:\n>")<EOL>vartype = l2[<NUM_LIT:2>].split("<STR_LIT:\n>", nvars)<EOL>del vartype[nvars]<EOL>topts             = dict(dsopts)<EOL>topts['<STR_LIT>']      = <NUM_LIT:0><EOL>topts['<STR_LIT>'] = '<STR_LIT>'<EOL>code  = "<STR_LIT>"<EOL>code += "<STR_LIT>"+tabname+self._sb._dsopts(topts)+"<STR_LIT>"<EOL>for i in range(nvars):<EOL><INDENT>code += "<STR_LIT>"+varlist[i]+"<STR_LIT>"<EOL><DEDENT>code += "<STR_LIT>"<EOL>ll = self.submit(code, "<STR_LIT:text>")<EOL>l2 = ll['<STR_LIT>'].rpartition("<STR_LIT>")<EOL>l2 = l2[<NUM_LIT:2>].partition("<STR_LIT:\n>")<EOL>varcat = l2[<NUM_LIT:2>].split("<STR_LIT:\n>", nvars)<EOL>del varcat[nvars]<EOL>try:<EOL><INDENT>sock = socks.socket()<EOL>if self.sascfg.tunnel:<EOL><INDENT>sock.bind(('<STR_LIT:localhost>', port))<EOL><DEDENT>else:<EOL><INDENT>sock.bind(('<STR_LIT>', port))<EOL><DEDENT>port = sock.getsockname()[<NUM_LIT:1>]<EOL><DEDENT>except OSError:<EOL><INDENT>print('<STR_LIT>')<EOL>return None<EOL><DEDENT>if self.sascfg.ssh:<EOL><INDENT>if not self.sascfg.tunnel:<EOL><INDENT>host = self.sascfg.hostip <EOL><DEDENT>else:<EOL><INDENT>host = '<STR_LIT:localhost>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>host = '<STR_LIT>'<EOL><DEDENT>rdelim = "<STR_LIT:'>"+'<STR_LIT>' % ord(rowsep.encode(self.sascfg.encoding))+"<STR_LIT>"<EOL>cdelim = "<STR_LIT:'>"+'<STR_LIT>' % ord(colsep.encode(self.sascfg.encoding))+"<STR_LIT>"<EOL>code  = "<STR_LIT>"<EOL>code += "<STR_LIT>"+host+"<STR_LIT::>"+str(port)+"<STR_LIT>"+str(self.sascfg.lrecl)+"<STR_LIT>"<EOL>code += "<STR_LIT>"+tabname+self._sb._dsopts(dsopts)+"<STR_LIT>"+cdelim+"<STR_LIT>"<EOL>for i in range(nvars):<EOL><INDENT>code += "<STR_LIT:'>"+varlist[i]+"<STR_LIT>"<EOL>if vartype[i] == '<STR_LIT:N>':<EOL><INDENT>if varcat[i] in self._sb.sas_date_fmts:<EOL><INDENT>code += '<STR_LIT>'+cdelim<EOL><DEDENT>else:<EOL><INDENT>if varcat[i] in self._sb.sas_time_fmts:<EOL><INDENT>code += '<STR_LIT>'+cdelim<EOL><DEDENT>else:<EOL><INDENT>if varcat[i] in self._sb.sas_datetime_fmts:<EOL><INDENT>code += '<STR_LIT>'+cdelim<EOL><DEDENT>else:<EOL><INDENT>code += '<STR_LIT>'+cdelim<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if not (i < (len(varlist)-<NUM_LIT:1>)):<EOL><INDENT>code += rdelim<EOL><DEDENT><DEDENT>code += "<STR_LIT>"<EOL>sock.listen(<NUM_LIT:1>)<EOL>self._asubmit(code, '<STR_LIT:text>')<EOL>r     = []<EOL>df    = None<EOL>datar = b'<STR_LIT>'<EOL>trows = kwargs.get('<STR_LIT>', None)<EOL>if not trows:<EOL><INDENT>trows = <NUM_LIT><EOL><DEDENT>newsock = (<NUM_LIT:0>,<NUM_LIT:0>)<EOL>try:<EOL><INDENT>newsock = sock.accept()<EOL>while True:<EOL><INDENT>data = newsock[<NUM_LIT:0>].recv(<NUM_LIT>)<EOL>if len(data):<EOL><INDENT>datar += data<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT>data  = datar.rpartition(colsep.encode()+rowsep.encode()+b'<STR_LIT:\n>')<EOL>datap = data[<NUM_LIT:0>]+data[<NUM_LIT:1>]<EOL>datar = data[<NUM_LIT:2>]<EOL>datap = datap.decode(self.sascfg.encoding, errors='<STR_LIT:replace>')<EOL>for i in datap.split(sep=colsep+rowsep+'<STR_LIT:\n>'):<EOL><INDENT>if i != '<STR_LIT>':<EOL><INDENT>r.append(tuple(i.split(sep=colsep)))<EOL><DEDENT><DEDENT>if len(r) > trows:<EOL><INDENT>tdf = pd.DataFrame.from_records(r, columns=varlist)<EOL>for i in range(nvars):<EOL><INDENT>if vartype[i] == '<STR_LIT:N>':<EOL><INDENT>if varcat[i] not in self._sb.sas_date_fmts + self._sb.sas_time_fmts + self._sb.sas_datetime_fmts:<EOL><INDENT>if tdf.dtypes[tdf.columns[i]].kind not in ('<STR_LIT:f>','<STR_LIT:u>','<STR_LIT:i>','<STR_LIT:b>','<STR_LIT:B>','<STR_LIT:c>','<STR_LIT:?>'):<EOL><INDENT>tdf[varlist[i]] = pd.to_numeric(tdf[varlist[i]], errors='<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if tdf.dtypes[tdf.columns[i]].kind not in ('<STR_LIT:M>'):<EOL><INDENT>tdf[varlist[i]] = pd.to_datetime(tdf[varlist[i]], errors='<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>tdf[varlist[i]].replace('<STR_LIT:U+0020>', np.NaN, True)<EOL><DEDENT><DEDENT>if df is not None:<EOL><INDENT>df = df.append(tdf, ignore_index=True)<EOL><DEDENT>else:<EOL><INDENT>df = tdf<EOL><DEDENT>r = []<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>print("<STR_LIT>")<EOL>if newsock[<NUM_LIT:0>]:<EOL><INDENT>newsock[<NUM_LIT:0>].shutdown(socks.SHUT_RDWR)<EOL>newsock[<NUM_LIT:0>].close()<EOL><DEDENT>sock.close()<EOL>ll = self.submit("<STR_LIT>", '<STR_LIT:text>')<EOL>return ll['<STR_LIT>']<EOL><DEDENT>newsock[<NUM_LIT:0>].shutdown(socks.SHUT_RDWR)<EOL>newsock[<NUM_LIT:0>].close()<EOL>sock.close()<EOL>if len(r) > <NUM_LIT:0> or df is None:<EOL><INDENT>tdf = pd.DataFrame.from_records(r, columns=varlist)<EOL>for i in range(nvars):<EOL><INDENT>if vartype[i] == '<STR_LIT:N>':<EOL><INDENT>if varcat[i] not in self._sb.sas_date_fmts + self._sb.sas_time_fmts + self._sb.sas_datetime_fmts:<EOL><INDENT>if tdf.dtypes[tdf.columns[i]].kind not in ('<STR_LIT:f>','<STR_LIT:u>','<STR_LIT:i>','<STR_LIT:b>','<STR_LIT:B>','<STR_LIT:c>','<STR_LIT:?>'):<EOL><INDENT>tdf[varlist[i]] = pd.to_numeric(tdf[varlist[i]], errors='<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if tdf.dtypes[tdf.columns[i]].kind not in ('<STR_LIT:M>'):<EOL><INDENT>tdf[varlist[i]] = pd.to_datetime(tdf[varlist[i]], errors='<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>tdf[varlist[i]].replace('<STR_LIT:U+0020>', np.NaN, True)<EOL><DEDENT><DEDENT>if df is not None:<EOL><INDENT>df = df.append(tdf, ignore_index=True)<EOL><DEDENT>else:<EOL><INDENT>df = tdf<EOL><DEDENT><DEDENT>return df<EOL>
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object.
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.
rowsep  - the row seperator character to use; defaults to '\n'
colsep  - the column seperator character to use; defaults to '\t'
port    - port to use for socket. Defaults to 0 which uses a random available ephemeral port