Hi. I would like to write this postgreSQL code:
cast(to_timestamp( (to_char( chartdate, 'DD-MM-YYYY' ) || substring(ne.text, 'Date/Time: [\[\]0-9*-]+ at ([0-9:]+)')), 'DD-MM-YYYYHH24:MI') as timestamp without time zone) as charttime
INTO FEDSQL or SAS SQL. Can anyone help?
Thank you.
You'll get faster responses if you post what the data looks like and what you need it to do instead. Some test data is helpful either way.
A rough guess, you're parsing some text field to get the time or date component, not sure.
@Zula wrote:
Hi. I would like to write this postgreSQL code:
cast(to_timestamp( (to_char( chartdate, 'DD-MM-YYYY' ) || substring(ne.text, 'Date/Time: [\[\]0-9*-]+ at ([0-9:]+)')), 'DD-MM-YYYYHH24:MI') as timestamp without time zone) as charttimeINTO FEDSQL or SAS SQL. Can anyone help?
Thank you.
Thanks.
See below comments:
-- charttime is always null for echoes.. -- however, the time is available in the echo text, e.g.: -- , substring(ne.text, 'Date/Time: [\[\]0-9*-]+ at ([0-9:]+)') as TIMESTAMP -- we can therefore impute it and re-create charttime , cast(to_timestamp( (to_char( chartdate, 'DD-MM-YYYY' ) || substring(ne.text, 'Date/Time: [\[\]0-9*-]+ at ([0-9:]+)')), 'DD-MM-YYYYHH24:MI') as timestamp without time zone) as charttime
Also, see below:
-- explanation of below substring: -- 'Indication: ' - matched verbatim -- (.*?) - match any character -- \n - the end of the line -- substring only returns the item in ()s -- note: the '?' makes it non-greedy. if you exclude it, it matches until it reaches the *last* \n , substring(ne.text, 'Indication: (.*?)\n') as Indication -- sometimes numeric values contain de-id text, e.g. [** Numeric Identifier **] -- this removes that text , case when substring(ne.text, 'Height: \(in\) (.*?)\n') like '%*%' then null
And the data looks like what before the statements shown? And What is the desired result?
Random bits of syntax descriptions of another language do not always help much with what the appropriate SAS code might be.
It also is not clear which bits may be syntax and which might be data file content descriptions.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.