Does anyone know how to convert number format into date format? For example, the following shows what my data looks like:
Date
20060306 |
20040727 |
20040407 |
20010423 |
All of data is shown as the number format BEST12. Informat 12. I want to convert them into these format YYMMDDN8. Informat YYMMDD6. in order to do a match afterwards. Could anyone tell me how to do it? Many Thanks in advance.
george
Are you sure? I don't think associating YYMMDD8 with a numeric variable that does not contain a "SAS Date" will produce the correct result. You have to read the "date string" using the proper date INFORMAT.
hello,
data have;
input Date;
datalines;
20060306
20040727
20040407
20010423
;
run;
data want;
set have;
date_c=put(date,8.);
date_n=input(date_c,yymmdd8.);
format date_n yymmddn8.;
run;
data have;
infile cards;
input date;
format date best12.;
cards;
20060306
20040727
20040407
20010423
;
run;
data want;
format date2 yymmddn8.;
set have;
date2 = input(put(date,8.),yymmdd8.);
run;
You could just stop at the format statement (same test data):
data want;
set have;
format date yymmdd8.;
run;
Are you sure? I don't think associating YYMMDD8 with a numeric variable that does not contain a "SAS Date" will produce the correct result. You have to read the "date string" using the proper date INFORMAT.
Yes, you are quite correct. Ignore my post.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.