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
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 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.