How to convert character variable to sas date

Reply
Occasional Contributor
Posts: 8

How to convert character variable to sas date

I am trying to convert charcter variable to sas date

EX: Ship_date=1,131,120.00

Can you plz help on this.

Respected Advisor
Posts: 4,662

Re: How to convert character variable to sas date

It would help knowing what generated that number, or better, what date it represents, as it does not look like the number behind a SAS date or a SAS datetime.

PG

PG
Occasional Contributor
Posts: 8

Re: How to convert character variable to sas date

Given data the variable name is Ship_date. It  displays 1,131,120.00

Super Contributor
Posts: 644

Re: How to convert character variable to sas date

In Excel this would correspond to a date in the year 5000, and in SAS sixty years later.  It does not make much sense to interpret it as a datetime value because that gives a SAS date in January 1960.  My guess is your data is corrupted and might possibly represent 11/13/12 in US style.

Richard

Occasional Contributor
Posts: 8

Re: How to convert character variable to sas date

Ok. I will check. Thank you.

Super Contributor
Posts: 358

Re: How to convert character variable to sas date

Hi:

We sometimes get dates like this from COBOL programs (because of lazy programmers at Y2K).  The first digit is sometimes the "century", so a "1" is 2000 and a blank is "1900".  Therefore your date is 2013 11 20.

The way we convert the date is to add 19000000 to the number and that give you a meaningful date value.

then read as YYYYMMDD

Ask a Question
Discussion stats
  • 5 replies
  • 443 views
  • 0 likes
  • 4 in conversation