I have imported a SAS dataset in python dataframe using Pandas read_sas(path)
function. REPORT_MONTH is a column in sas dataset defined and saved as DATE9. format. This field is imported as float64 datatype in dataframe and having numbers which is basically a sas internal numbers for storing a date in a sas dataset. Now wondering how can I convert this originally a date field into a date field in dataframe?
Asked
Active
Viewed 482 times
0

mechanical_meat
- 163,903
- 24
- 228
- 223

FarrukhJ
- 139
- 1
- 8
-
Could you give an example of your SAS internal numbers? – mechanical_meat Jul 22 '16 at 04:10
-
Given below is the tuple of three sample I get from my dataset. First column is the original date and second is the sas own internal number for storing the date in sas dataset: {01FEB2014 : 19755, 01DEC2013 : 19693, 01OCT2015 : 20362} – FarrukhJ Jul 22 '16 at 04:52
1 Answers
0
I don't know how python stores dates, but SAS stores dates as numbers, counting the number of days from Jan 1, 1960. Using that you should be able to convert it in python to a date variable somehow.
I'm fairly certain that when data is imported to python the formats aren't honoured so in this case it's easy to work around this, in others it may not be.
There's probably some sort of function in python to create a date of Jan 1, 1960 and then increment by the number of days you get from the imported dataset to get the correct date.

Reeza
- 20,510
- 4
- 21
- 38