BookmarkSubscribeRSS Feed
KalaBhairava
Quartz | Level 8

how to convert is8601dt. numeric  format to is8601dt character format

8 REPLIES 8
ChrisNZ
Tourmaline | Level 20

What on earth is  is8601dt. numeric  format?

 

Is your numeric variable a SAS date time?

 

in that case  CHARVAR=put(MYDATETIME,is8601dt.)  may be want you want.

 

If not, show what you have (variable type, format and value) and what you want.

 

 

KalaBhairava
Quartz | Level 8

My variable format is in IS8601DT19. (neumeric) but i want to convert it into IS8601DT19 chracter  for SDTM

ChrisNZ
Tourmaline | Level 20
KalaBhairava
Quartz | Level 8
Yes ,but $19 format is coming.
ChrisNZ
Tourmaline | Level 20

 Show what you have (variable type, format and value) and what you want.

ballardw
Super User

@KalaBhairava wrote:
Yes ,but $19 format is coming.

You specifically requested a character value. Unless you  assign a custom format they are ALL going to have a $x. format.

Or is the actual length the question? The length would depend on the width specified for the format when using the PUT function.

CHARVAR=put(MYDATETIME,is8601dt.) 

Defaults to a length of 19 if not specified. If you want longer result then use IS8601DT26. (maximum length for the format is 26) if you expect/need decimal portions then IS8601DT26.d   where d can range from 0 to 6.

 

Kurt_Bremser
Super User

Please supply example data and be more specific. As is, your question makes no sense.

If a datetime value is already formatted with a e8601 format, it will always display as such and be written to external files as such.

Converting it to character serves no purpose and only deprives you of the use of all the SAS date- and datetime- related tools. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do you mean ISO dates, as is used in CDISC for instance?  If so then:

data want;
  datetime_date="01JAN2018 01:12"dt;
  iso_date=datetime_date;
  string_date=put(datetime_date,e8601dt.);
  format datetime_date datetime. iso_date e8601dt.;
run;

This shows a datetime variable, which can be formatted to ISO, and a character version.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 8 replies
  • 1761 views
  • 0 likes
  • 5 in conversation