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 :
DATA TEST1c;
SET TEST1B;
DOB= INPUT (DOB, $8.);
FORMAT DOB yymmd.;
RUN;
It does not seem to be working. Any help is appreciated.
Thank you
Your question is similar to the next post. See solution there:
https://communities.sas.com/t5/Base-SAS-Programming/Informat-for-date-in-the-form-MM-YYYY/m-p/326564
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.
If you have a character string "08.1960" that you want to change to "08-1960" that is pretty easy:
dob = translate(dob, '-', '.');
However:
You might start by running PROC CONTENTS on your data set and describing the results for DOB.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.