## Date Formats

Solved
Super Contributor
Posts: 1,041

# Date Formats

Hello,

I have 4-Aug-2016 (\$20.) , 05-Aug-2016 (\$20.) and I want to convert it into a proper date foramt. The following does not work. Could someone suggest a proper method to do it?

data want;

set have;

Date2= input(Date,worddate.);

format Date2 date10.;

run;

Thanks

Accepted Solutions
Solution
‎10-24-2016 11:22 AM
Super User
Posts: 9,402

## Re: Date Formats

One example:

```data have;
length dt \$20;
dt="4-Aug-2016"; output;
dt="05-aug-2016"; output;
run;

data want;
set have;
d2=input(compress(dt," -"),date9.);
format d2 date9.;
run;```

All Replies
Solution
‎10-24-2016 11:22 AM
Super User
Posts: 9,402

## Re: Date Formats

One example:

```data have;
length dt \$20;
dt="4-Aug-2016"; output;
dt="05-aug-2016"; output;
run;

data want;
set have;
d2=input(compress(dt," -"),date9.);
format d2 date9.;
run;```
Super Contributor
Posts: 1,041

## Re: Date Formats

Hello,
Just wondering why is there a space before the hyphen when using compress function?
Super User
Posts: 9,402

## Re: Date Formats

Typo, its not needed.

Super Contributor
Posts: 1,041

## Re: Date Formats

First I thought the space is used to let SAS to keep anything before that but then I removed the space and still it worked. Just double checking. Thank you again
SAS Super FREQ
Posts: 810

## Re: Date Formats

The answer is already solved, just wanted to mention, that the date11 informat can read the dates that are shown.

See sample code below:

``````data have;
length dt \$20;
dt="4-Aug-2016"; output;
dt="05-aug-2016"; output;
run;

data want;
set have;
d2 = input(dt, date11.);
format d2 date9.;
run;``````
☑ This topic is solved.