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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.