SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Change date format

Regular Contributor
Posts: 185

Change date format

Hi Team,

I have dates stored in character format. They look like - "15Jul2014". I need to convert it into 2014-Jul-15 i.e. YYYY-MMM-DD . Is there any easy way to convert it?

Thanks in anticipation!

SAS Employee
Posts: 85

Re: Change date format

What software are you using? Base SAS, Enterprise Guide, SAS Data Management, SAS Data Integration, etc.?


Regular Contributor
Posts: 185

Re: Change date format

I am using Base SAS. Does your answer vary in Base SAS and SAS Enterprise Guide? Thanks!

Super User
Posts: 10,686

Re: Change date format

You need to define a format for yourself .

Code: Program

proc format;
picture fmt
data x;
format a fmt12.

Xia Keshan

Super User
Super User
Posts: 9,402

Re: Change date format


Alternatively just create a text field:

data want;

     set have;

     length new_date $10;



Posts: 23

Re: Change date format


Is your date really a character variable? If so, I would urge you to convert it into a SAS date value first.

If your date is stored as a SAS date value, RW9's solution won't work without additional coding. If it is a character value, then you won't be able to do any calulations with it without code to do that transformation to a SAS date value. Xia's solution is the easiest way of dealing with the fact that SAS does not have every possible date format available. Only change I would make is I would use a more descriptive format name than "fmt".

IMHO, there is no reason to represent a date as a character variable in a SAS table or view, UNLESS you are dealing with complex ISO8601 dates and need to calculate ISO durations and intervals using CALL IS8601_CONVERT.


Ask a Question
Discussion stats
  • 5 replies
  • 1 like
  • 5 in conversation