Hi SAS community, I am trying to work with this variable (please see screenshot) which SAS is treating as a "datetime16." I would like to create a separate date variable that has a format of "01JAN22" and a time variable of "07:26:27". many thanks
dateVar = datepart(seriesTimeStamp);
format datevar date9.;
timeVar = timepart(seriesTimeStamp);
format timeVar time8.;
TIMEPART and DATEPART to extract the date/time components of a datetime variable.
You don't need a new variable for the date. Just assign the format DTDATE7. to this variable. If you want a time variable, use the TIMEPART function.
dateVar = datepart(seriesTimeStamp);
format datevar date9.;
timeVar = timepart(seriesTimeStamp);
format timeVar time8.;
TIMEPART and DATEPART to extract the date/time components of a datetime variable.
thanks so much!
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.