EDIT 27/09/2021 19:20
If I change Length to :
- 1 : return D
- 2 : return 23/12/2020
- 3-8: return 04/09/2021 (expected)
- more than 9 : an error raise
I don't understand...
EDIT 27/09/2021 18:30
I think problem may comes from format of date that should be number of days since 1960 for SAS So I have converted my date like this, and change format of dataset to ddmmyy10.
But now, I can open xpt file but when I want to see data, I got an error :
I want to produce xpt files (SAS transfert format) from Pandas dataframes but do not understand how xport.v56.dump function works.
Dataframe may contain integer, float, string and date/datetime but it seems that xpt library dataset only have Character or Numeric not Date/Datetime.
If I try to xport field with datetime, I get an error Could not coerce column {column!r} to {dtype}
...
For example, variable #17 and #18 above should be datetime
Is it possible to define Type 'Datetime' with ddmmyy10. SAS format?
Maybe I misunderstand something with xpt files format?
CodePudding user response:
If I change Length to 7 or 8 it works but not with >=9
This is your issue! Length, in SAS, for numeric variables is the number of bytes used to store the number. All numerics in SAS are 8 byte numerics; you can't store a numeric with more than 8 bytes. You can use less, but shouldn't.
Length in numeric variables is not the display width, that is controlled in the format. In character variables, in single byte character sets, it does overlap (they're the same, length and display width, for the most part), hence the common confusion.