I have the dataset with a column of DATE. However, my supervisor arranged the file from different sources. So the column of DATE in the excel file are not all in DATE formate. eg.
There are both 25/06/2001, and 20000312 in that column, which the first is DATE format, but the second is recognized as numerical value. It's fairly easy to input just with either of them. But how to input both types of DATE presenting in the same column?
Thank you very much.
And i want convert both to the format of yymmddn8., ie(20000312, this is data format in SAS, but not in EXCEL of my original data file.).
data test;
input a $20.;
if length (trim(a)) = 10 then do;
year = substr(trim(a),7,4);
month= substr(trim(a),4,2);
day = substr(trim(a),1,2);
b = mdy(month,day,year);
end;
if length(trim(a)) = 8 then do;
year = substr(trim(a),1,4);
month= substr(trim(a),5,2);
day = substr(trim(a),7,2);
b=mdy(month,day,year);
end;
cards;
25/05/2001
20000312
19990909
12/01/2009
;
run;
proc print data = test;
var b;
format b yymmdd8.;
run;
Thanks for all replies... Those programs all worked.. But my question is how to find a generalized way to input hybrid date form. ‘/' is just a particular case. Also like "-" , 01032000, 20000103, 2000-01-03, etc. I have hundreds groups of data, writing a Macro for input date to "find" these case is not practical.