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