how to convert date wich is in MM/DD/YYYY to YYYYMMDD in enterprise SAS on unix platform

Hi,
   Here is my data set by name "file1.sas7b.dat"

                  Patient ID           DOB
1.              2SRE3456            01/12/2014
2.              S456HRW             1/2/2014
3.              GT567575            02/01/2014

Here is my SAS Enterprise program to convert DOB to YYYYMMDD. But it is not working... ANy help will be greatly appreciated

Data file2_YYYYMMDD;
   set file1;
New_Date = Input(TRIM(DOB),MMDDYY10.);
Run;
raniravsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IanStatisticianCommented:
Hi there

The variable  DOB  in your sas data set may be either

A numeric variable being stored as the number of days since the date origin and displayed using an associated format probably  mmddyy10.

or

A character variable of length at least 10 that contains the characters   "0" and "1" and "/" and "1" and "2" and "/" and "2" and "0" and "1" and "4".

In the first case all you need to do is change the format as in

data file2_YYYYMMDD;
   set file1;
   format DOB yyyymmdd.;
run; 

Open in new window


In the second case your code will work except you will need to provide a format for New_Date similar to above.

...

run proc contents on the file is an easy way to find out which case you have.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.