Hi all,
I have below data:
And attributes are as below:
I would like to convert it to iso8601 character format. Could you please give me some idea how to convert this type of data into ISO 8601 character?
Thanks,
Adi
Here's an example. As you can see, a numeric variable formatted with the ISO format and a character variable created using the same format both look the same. I consider it a best practice to always store dates as numeric variables and control the display with a FORMAT statement. Dates stored as character strings are rarely useful.
Hope this helps,
Cynthia
@chinna0369 wrote:
Hi all,
I have below data:
And attributes are as below:
I would like to convert it to iso8601 character format. Could you please give me some idea how to convert this type of data into ISO 8601 character?
Thanks,
Adi
Which specific ISO format? SAS has about 20 different ISO format that could be used. Look in the documentation for B8601 and E8601 formats.
Since your current value is CHARACTER likely the first step would be to get a SAS date time value using the input function and then PUT the result into a character value using the appropriate format. Or create a datetime variable and just associate the desired format. Then if you want to display the value as something else you may only need to change a format and not modify the data set.
Thank you for your reply!
Can you give me some example code by using b8601.
Thanks,
Adi
Here's an example. As you can see, a numeric variable formatted with the ISO format and a character variable created using the same format both look the same. I consider it a best practice to always store dates as numeric variables and control the display with a FORMAT statement. Dates stored as character strings are rarely useful.
Hope this helps,
Cynthia
Thank you so much Cynthia_sas
Hi Cynthia,
Right now we are getting date as below:
what do I need to use if want to get as below?
Thanks,
Adi
Hi:
I'm not on a machine where I can do documentation right now. You can look in the list of formats for the right format to get the date the way you want.
cynthia
That looks like you may want the E8601DTw.d format but the shortest version of that is 19 characters and will show seconds.
If that is unacceptable you will have to create a custom format.
Hi all,
Thanks, I got it. I changed it to " E8601DTw.d" it looks fine to me.
Thanks,
Adithya
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.