1

I'd like to load a SAS7BDAT file into a pandas dataframe, and then into a database.

I understand that pandas.read_sas allows loading a SAS7BDAT, but I'd also like to retrieve the SAS column labels and also store this in the database. (Note -- this is different to the column name and is usually a long text description of the column).

Is it possible to load the SAS text label for each column with Pandas?

Joe
  • 62,789
  • 6
  • 49
  • 67
user48956
  • 14,850
  • 19
  • 93
  • 154
  • 1
    AFAIK - pandas does not maintain a counterpart to *column labels*. There are discussions (see [here](https://github.com/pandas-dev/pandas/issues/2485) and [here](http://stackoverflow.com/questions/14688306/adding-meta-information-metadata-to-pandas-dataframe)) of storing metadata in dataframes but now only remain with extensions like hdf5 and pytables. – Parfait Apr 04 '17 at 18:21

1 Answers1

-1

I achieved this by using SAS7BDAT class instead of Dataframe and when I inspected the columns, I was able to see labels as well

with SAS7BDAT('xxx.sas7bdat',encoding='latin-1') as sas:
for row in sas:

sas-> columns will have name as well as label