def dataframe2sasdata(self, df: '<STR_LIT>', table: str ='<STR_LIT:a>', <EOL>libref: str ="<STR_LIT>", keep_outer_quotes: bool=False):
input  = "<STR_LIT>"<EOL>card   = "<STR_LIT>"<EOL>format = "<STR_LIT>"<EOL>length = "<STR_LIT>"<EOL>dts    = []<EOL>ncols  = len(df.columns)<EOL>for name in range(ncols):<EOL><INDENT>input += "<STR_LIT:'>"+str(df.columns[name])+"<STR_LIT>"<EOL>if df.dtypes[df.columns[name]].kind in ('<STR_LIT:O>','<STR_LIT:S>','<STR_LIT>','<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>col_l = df[df.columns[name]].astype(str).apply(self._getbytelen).max()<EOL><DEDENT>except Exception as e:<EOL><INDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>"+str(e))<EOL>return None<EOL><DEDENT>if col_l == <NUM_LIT:0>:<EOL><INDENT>col_l = <NUM_LIT:8><EOL><DEDENT>length += "<STR_LIT>"+str(df.columns[name])+"<STR_LIT>"+str(col_l)<EOL>if keep_outer_quotes:<EOL><INDENT>input  += "<STR_LIT>"<EOL><DEDENT>dts.append('<STR_LIT:C>')<EOL><DEDENT>else:<EOL><INDENT>if df.dtypes[df.columns[name]].kind in ('<STR_LIT:M>'):<EOL><INDENT>length += "<STR_LIT>"+str(df.columns[name])+"<STR_LIT>"<EOL>input  += "<STR_LIT>"<EOL>format += "<STR_LIT:'>"+str(df.columns[name])+"<STR_LIT>"<EOL>dts.append('<STR_LIT:D>')<EOL><DEDENT>else:<EOL><INDENT>length += "<STR_LIT>"+str(df.columns[name])+"<STR_LIT>"<EOL>if df.dtypes[df.columns[name]] == '<STR_LIT:bool>':<EOL><INDENT>dts.append('<STR_LIT:B>')<EOL><DEDENT>else:<EOL><INDENT>dts.append('<STR_LIT:N>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>code = "<STR_LIT>"<EOL>if len(libref):<EOL><INDENT>code += libref+"<STR_LIT:.>"<EOL><DEDENT>code += table+"<STR_LIT>"<EOL>if len(length):<EOL><INDENT>code += "<STR_LIT>"+length+"<STR_LIT>"<EOL><DEDENT>if len(format):<EOL><INDENT>code += "<STR_LIT>"+format+"<STR_LIT>"<EOL><DEDENT>code += "<STR_LIT>"+input+"<STR_LIT>"<EOL>self._asubmit(code, "<STR_LIT:text>")<EOL>code = "<STR_LIT>"<EOL>for row in df.itertuples(index=False):<EOL><INDENT>card  = "<STR_LIT>"<EOL>for col in range(ncols):<EOL><INDENT>var = str(row[col])<EOL>if   dts[col] == '<STR_LIT:N>' and var == '<STR_LIT>':<EOL><INDENT>var = '<STR_LIT:.>'<EOL><DEDENT>elif dts[col] == '<STR_LIT:C>' and var == '<STR_LIT>':<EOL><INDENT>var = '<STR_LIT:U+0020>'<EOL><DEDENT>elif dts[col] == '<STR_LIT:B>':<EOL><INDENT>var = str(int(row[col]))<EOL><DEDENT>elif dts[col] == '<STR_LIT:D>':<EOL><INDENT>if var == '<STR_LIT>':<EOL><INDENT>var = '<STR_LIT:.>'<EOL><DEDENT>else:<EOL><INDENT>var = str(row[col].to_datetime64())[:<NUM_LIT>]<EOL><DEDENT><DEDENT>card += var<EOL>if col < (ncols-<NUM_LIT:1>):<EOL><INDENT>card += chr(<NUM_LIT:3>)<EOL><DEDENT><DEDENT>code += card+"<STR_LIT:\n>"<EOL>if len(code) > <NUM_LIT>:<EOL><INDENT>self._asubmit(code, "<STR_LIT:text>")<EOL>code = "<STR_LIT>"<EOL><DEDENT><DEDENT>self._asubmit(code+"<STR_LIT>", "<STR_LIT:text>")<EOL>ll = self.submit("<STR_LIT>", '<STR_LIT:text>')<EOL>return<EOL>
This method imports a Pandas Data Frame to a SAS Data Set, returning the SASdata object for the new Data Set.
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
keep_outer_quotes - for character columns, have SAS keep any outer quotes instead of stripping them off.