Help using Base SAS procedures

Convert SAS date to MS standard date

Not applicable
Posts: 1

Convert SAS date to MS standard date


I am trying to convert SAS date (08JUN2009) to microsoft standard date the method I have used is as follows -

PolstDt+21916 as SysProdDte label='SysProdDte' format=8.,

Any help appreciated.

Super Contributor
Posts: 297

Re: Convert SAS date to MS standard date

My understanding is that ms needs a datetime field. This is what I've used.

In your case, I think you will have to add time 00:00:00 to the sas date and then go through the steps below. Hopefully this will get you started.

Asof=sasdate plus sastime as a SAS datetime value;**Build sas datetime value;
**Build microsoft date serial;
AS_Of=(int(asof/86400) + 21916) + ((asof-(int(asof/86400)*86400))/86400);
Super Contributor
Super Contributor
Posts: 3,176

Re: Convert SAS date to MS standard date

You may want to entertain the question: what is it that you are trying to achieve - as in the final result? Then consider this SAS DOC reference, with relevance to external date formats:

So, if you have an alternate baseline where 0 represents some particular point in time (date or date/time), then my suggestion is that you decrement from SAS DATE (days since 1/1/1960) or DATETIME (seconds since 1/1/1960) back to your baseline DATE/DATETIME representation, using the quite-useful MDY and/or the DHMS functions -- let SAS do the calculations for you rather than attempting to handle the calculation, instead.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation