So it's DB2 but you are reading it from a file?
If you access DB2 directly the SAS/ACCESS libname engine maps DB2 timestamps to SAS datetime auotmatically.
if you can't find any suitable existing informat, you can create your own:
SAS Help Center: Syntax: PROC FORMAT PICTURE Statement
@LinusH wrote:
So it's DB2 but you are reading it from a file?
If you access DB2 directly the SAS/ACCESS libname engine maps DB2 timestamps to SAS datetime auotmatically.
if you can't find any suitable existing informat, you can create your own:
SAS Help Center: Syntax: PROC FORMAT PICTURE Statement
Agree with your first point. ...plus rounding the floating point number to the 6th decimal.
If reading a string is required: I don't believe a picture FORMAT will help as it's about the need for an INformat.
You will need to convert this source string to a pattern for which there is a SAS infomat. Let me know if below conversion is working for you.
data demo;
input have_string $25.;
have_string=prxchange('s/^(\d+-\d+-\d+).(\d+).(\d+).(\d+.*)$/$1T$2:$3:$4/oi',1,strip(have_string));
have_dttm=input(strip(have_string),e8601dt26.6);
/*Get the current timestamp*/;
Current_time = DATETIME();
/* subtract 14 hours (50400 seconds) */
_14_hours_ago = intnx('dthour',current_time,-14,'s');
datalines;
2023-09-05-06.15.16.130035
2023-09-05T06:15:16.130035
;
proc print data=demo;
format have_dttm Current_time _14_hours_ago datetime25.6;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.