Convert date format to character format

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Convert date format to character format

I have a column with date format E8601DT.  (2015-06-07T00:00:00). How do i change this column to character with the exact same value.

 

 

 


Accepted Solutions
Solution
‎02-04-2016 11:07 AM
Super User
Posts: 10,552

Re: Convert date format to character format

One would tend to ask why as SAS date values are easier to manipulate if needed...

 

The basic answer is you can't convert an existing variable. You can create a new data set with a similarly named variable holding the other version.

 

 

Data want;

   set have (rename=(datevar=Olddatevar));

   datevar = put(olddatevar,E8601DT19.);

run;

 

Or use a similar approach to just add a new text version.

View solution in original post


All Replies
Solution
‎02-04-2016 11:07 AM
Super User
Posts: 10,552

Re: Convert date format to character format

One would tend to ask why as SAS date values are easier to manipulate if needed...

 

The basic answer is you can't convert an existing variable. You can create a new data set with a similarly named variable holding the other version.

 

 

Data want;

   set have (rename=(datevar=Olddatevar));

   datevar = put(olddatevar,E8601DT19.);

run;

 

Or use a similar approach to just add a new text version.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 266 views
  • 2 likes
  • 2 in conversation