Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Converting ISO8601 interval string to time/numeric format in VA

Reply
Occasional Contributor
Posts: 7

Converting ISO8601 interval string to time/numeric format in VA

Hello,

 

For the last week I have been using SAS VA for visualization purposes. Now I am hoping to convert strings expressed in ISO8601 interval format, such as "-PT20M" and "PT24H", to time (preferable) or numeric format so that "-PT20M" would be -00:20:00 in time format or just -20 in numeric format and respectively "PT24H" would be 24:00:00 or 24. Answers presented here are only applicable to base SAS situations.

 

I am starting to wonder whether I have to implement some sort of IF ELSE fix...I hope not...

 

Thank you for your answers in advance.

Super User
Super User
Posts: 9,866

Re: Converting ISO8601 interval string to time/numeric format in VA

Occasional Contributor
Posts: 7

Re: Converting ISO8601 interval string to time/numeric format in VA

Hello @RW9 and thank you for your swift reply!

 

I'm afraid that I have already looked into that page and found it useless because firstly it doesn't provide information about their usage and secondly because SAS VA only seems to support four formats for strings (uppercasing, putting the string in double quotes, taking it raw "$w.d" and a fourth I can't remember at the moment.

Super User
Super User
Posts: 9,866

Re: Converting ISO8601 interval string to time/numeric format in VA

Sorry, can't help then as I don't use VA.  In coding you would use formats like:

want=input(have,<format>);

Don't even know if you can do coding in VA.

SAS Super FREQ
Posts: 831

Re: Converting ISO8601 interval string to time/numeric format in VA

You should convert these duration values before loading the data to be used by Visual Analytics, since there are no operators within VA to handle this.

 

Find below an example on how to convert an ISO duration value into a SAS time value.

 

data test;
  infile cards;
  input iso8601_int : $32.;

  length newtime 8;
  call is8601_convert("du", "du", iso8601_int, newtime);

  format newtime time.;
cards;
-PT20M
PT24H
PT25H
P3D
;

The $N8601B. informat converts a duration into a character representation, that later can be used with the CALL IS8601_CONVERT routine.

 

See also this paper https://www.pharmasug.org/proceedings/2012/DS/PharmaSUG-2012-DS22-SAS.pdf for additional information

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 133 views
  • 0 likes
  • 3 in conversation