BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

how to replace the old char column into date format?

 

txn_inf
2015/5/7 9:13:59
2015/2/7 5:43:11
1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12
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;

View solution in original post

3 REPLIES 3
kiranv_
Rhodochrosite | Level 12
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-
Quartz | Level 8
hi~Would you please change it into yyyymmdd hh:mm:ss date format,but not yyyymmdd
Tom
Super User Tom
Super User

@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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 7875 views
  • 0 likes
  • 3 in conversation