def sasdata2dataframeCSV(self, table: str, libref: str ='<STR_LIT>', dsopts: dict = None, tempfile: str=None, tempkeep: bool=False, **kwargs) -> '<STR_LIT>':
dsopts = dsopts if dsopts is not None else {}<EOL>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>if libref:<EOL><INDENT>tabname = libref+"<STR_LIT:.>"+table<EOL><DEDENT>else:<EOL><INDENT>tabname = table<EOL><DEDENT>tmpdir  = None<EOL>if tempfile is None:<EOL><INDENT>tmpdir = tf.TemporaryDirectory()<EOL>tmpcsv = tmpdir.name+os.sep+"<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>tmpcsv  = tempfile<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>if self.sascfg.ssh:<EOL><INDENT>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 not self.sascfg.tunnel:<EOL><INDENT>host = self.sascfg.hostip  <EOL><DEDENT>else:<EOL><INDENT>host = '<STR_LIT:localhost>'<EOL><DEDENT>code  = "<STR_LIT>"+host+"<STR_LIT::>"+str(port)+"<STR_LIT>"+str(self.sascfg.lrecl)+"<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>host = '<STR_LIT>'<EOL>code = "<STR_LIT>"+tmpcsv+"<STR_LIT>"+str(self.sascfg.lrecl)+"<STR_LIT>"<EOL><DEDENT>code += "<STR_LIT>"+tabname+self._sb._dsopts(dsopts)+"<STR_LIT>"<EOL>for i in range(nvars):<EOL><INDENT>if vartype[i] == '<STR_LIT:N>':<EOL><INDENT>code += "<STR_LIT:'>"+varlist[i]+"<STR_LIT>"<EOL>if varcat[i] in self._sb.sas_date_fmts:<EOL><INDENT>code += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if varcat[i] in self._sb.sas_time_fmts:<EOL><INDENT>code += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if varcat[i] in self._sb.sas_datetime_fmts:<EOL><INDENT>code += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>code += '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>code += "<STR_LIT>"<EOL>ll = self.submit(code, "<STR_LIT:text>")<EOL>dts = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>if dts == '<STR_LIT>':<EOL><INDENT>dts = {}<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>dts[varlist[i]] = '<STR_LIT:float>'<EOL><DEDENT>else:<EOL><INDENT>dts[varlist[i]] = '<STR_LIT:str>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>dts[varlist[i]] = '<STR_LIT:str>'<EOL><DEDENT><DEDENT><DEDENT>code  = '<STR_LIT>'<EOL>code  = "<STR_LIT>"<EOL>if self.sascfg.ssh:<EOL><INDENT>csv = open(tmpcsv, mode='<STR_LIT:wb>')<EOL>sock.listen(<NUM_LIT:1>)<EOL>self._asubmit(code, '<STR_LIT:text>')<EOL>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 not len(data):<EOL><INDENT>break<EOL><DEDENT>csv.write(data)<EOL><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>ll = self.submit("<STR_LIT>", '<STR_LIT:text>')<EOL>csv.close()<EOL>df = pd.read_csv(tmpcsv, index_col=False, engine='<STR_LIT:c>', dtype=dts, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>ll = self.submit(code, "<STR_LIT:text>")<EOL>df = pd.read_csv(tmpcsv, index_col=False, engine='<STR_LIT:c>', dtype=dts, **kwargs)<EOL><DEDENT>if tmpdir:<EOL><INDENT>tmpdir.cleanup()<EOL><DEDENT>else:<EOL><INDENT>if not tempkeep:<EOL><INDENT>os.remove(tmpcsv)<EOL><DEDENT><DEDENT>for i in range(nvars):<EOL><INDENT>if varcat[i] in self._sb.sas_date_fmts + self._sb.sas_time_fmts + self._sb.sas_datetime_fmts:<EOL><INDENT>df[varlist[i]] = pd.to_datetime(df[varlist[i]], errors='<STR_LIT>')<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.
dsopts   - data set options for the input SAS Data Set
port     - port to use for socket. Defaults to 0 which uses a random available ephemeral port
tempfile - file to use to store CSV, else temporary file will be used.
tempkeep - if you specify your own file to use with tempfile=, this controls whether it's cleaned up after using it