DATA Step, Macro, Functions and more

format date

New User
Posts: 1

format date

Good Afternoon,


I have the following date format mm.yyyy (e.g 08.1960) and I need to put into the format of yyyy-mm (e.g 08-1960).  I have already done the following :




DOB= INPUT (DOB, $8.);

FORMAT DOB yymmd.;



It does not seem to be working. Any help is appreciated.


Thank you

Trusted Advisor
Posts: 1,699

Re: format date

Posted in reply to biotelemetry

Your question is similar to the next post. See solution there:

Super User
Posts: 12,365

Re: format date

Posted in reply to biotelemetry

You should describe how something "is not working". Error? Post log and error message No output? Post log and any warnings or messages Unexpected output? Post input data and expected output.


Very likely your DOB variabe is numeric. You cannot have a character and numeric variable in a dataset with the same name which you attempted with the INPUT and a $ informat. Also Format with a datetype format is only going to work with a numeric value and will only make sense if the variable were read correctly. FORMATS control how the value is displayed, it does not change the actual content.

Super User
Posts: 6,203

Re: format date

Posted in reply to biotelemetry

If you have a character string "08.1960" that you want to change to "08-1960" that is pretty easy:


dob = translate(dob, '-', '.');




  • What you have is not clear.  Is DOB actually a date, or is it a character string?
  • What you want is not clear.  The "08-1960" is not a match for "yyyy-mm"

You might start by running PROC CONTENTS on your data set and describing the results for DOB.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation