Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert character dates into numeric

is there a way to convert a character date for example: 11-1900 that is November 1900 into a numeric date? Thank you in advance. I’m familiar with dates made by ddmmyy but not with only mmyy.

Best

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could use the ANYDTDTE. informat. But note that is a GUESSING procedure that tries to figure out if the string matches any of a number of different styles of representing dates. Might be better to just add your own day of the month prefix and use the DDMMYY informat instead. Then strange values will not accidentally result in valid but strange date values.

data have;
  input string $ ;
cards;
11-1900
12-2020
;

data want;
  set have;
  date1= input(string,anydtdte.);
  date2= input('01-'||string,ddmmyy10.);
  format date1 date2 date9.;
run;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading