Hello,
how can we translate a character into date format,
here is an example of my data: 2022-01-01 04:12:30.9808034 -05:00
thank you.
If you truly only need the date portion this is probably easiest:
data example; x= "2022-01-01 04:12:30.9808034 -05:00"; y= input(x,yymmdd10.); format y yymmdd10.; run;
If you need the time and time zone info you need to get used to dealing with SAS terminology of date, time and datetime as DATE values use different units, days, than time and datetime values which use seconds.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
Not being pedantic, but this is a datetime, not a date and SAS treats them differently.
A date is stored as the number of days from January 1, 1960.
A datetime is stored as the number of seconds from January 1, 1960.
Do you want a date or datetime read in?
Here's a great, but longer and in depth, reference for dates and times in SAS
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/...
@Eugenio211 wrote:
Hello,
how can we translate a character into date format,
here is an example of my data: 2022-01-01 04:12:30.9808034 -05:00
thank you.
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!
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.