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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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