0
votes

We read SAS xpt files to load data in .net. Everything works fine but recently we have encountered a problem where the customer has stored date as a numeric value in a column and provided a Format in the file header. The SAS viewer can display that data correctly using the given format but we have to load that data in .net in our program and we don't require SAS.

I recently found out that you can use the SaS LocalProvider with OLEDB but it turns out that it does not support Numeric formatting. So we are ending up with the wrong data in columns where data is stored as a numeric value with a format provided for it.

Can anyone please help me understand and resolve the issue with probably some code sample. I have looked around for code samples in .Net but with no luck so far for this issue.

Thanks in advance.

Regards,

Nasir

1

1 Answers

1
votes

SAS Date values are stored as the number of days since Jan 1, 1960.

122
123  data _null_;
124  x=today();
125  put x=;
126  run;

x=19410

Today (2/21/2013) for example is 19410 days since 1/1/1960. Assuming you know your own software's date format (probably some number of days since some other date), you can perform the transformation on your own.

If it's relevant, SAS datetime values are # of seconds since 1/1/1960 00:00:00 .

128  data _null_;
129  x=datetime();
130  put x=;
131  run;

x=1677052885.5
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds

Again, that's the time as of 08:00 2/21/2013.