01-23-2017 02:48 PM
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.
01-23-2017 03:04 PM
Your question is similar to the next post. See solution there:
01-23-2017 03:20 PM
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.
01-23-2017 03:36 PM
If you have a character string "08.1960" that you want to change to "08-1960" that is pretty easy:
dob = translate(dob, '-', '.');
You might start by running PROC CONTENTS on your data set and describing the results for DOB.