how to convert is8601dt. numeric format to is8601dt character format
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.
My variable format is in IS8601DT19. (neumeric) but i want to convert it into IS8601DT19 chracter for SDTM
Show what you have (variable type, format and value) and what you want.
@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.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.