how to replace the old char column into date format?
txn_inf |
2015/5/7 9:13:59 |
2015/2/7 5:43:11 |
data have;
txn_inf = "2015/5/7 9:13:59";
output;
txn_inf = "2015/2/7 5:43:11";
output;
run;
data want;
set have;
new_date= datepart(input(txn_inf, ANYDTDTM.));
format new_date date9.;
run;
data have;
txn_inf = "2015/5/7 9:13:59";
output;
txn_inf = "2015/2/7 5:43:11";
output;
run;
data want;
set have;
new_date= datepart(input(txn_inf, ANYDTDTM.));
format new_date date9.;
run;
@Geo- wrote:
hi~Would you please change it into yyyymmdd hh:mm:ss date format,but not yyyymmdd
So you actually want a DATETIME value and not a DATE value as your subject line says?
If so then use the ANYDTDTM. informat instead of the ANYDTDTE. informat.
Why would you like to print it using that format? What is wrong with just using the normal DATETIME19. format? Which would look like: 17NOV2018:20:42:01
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.