BookmarkSubscribeRSS Feed
daid13
Calcite | Level 5

So I'm working on writing a proper suite of automated tests for a library of statistical analysis macros used for analysis of medical trials. And updating the existing macros to follow better practices, such as handling invalid input and managing edge cases.

 

As I'm working with medical data, this needs to follow SDTM which mandates extended ISO8601 date format, with a few additional limitations as specified by SDTMIG. This means SAS numeric dates are not part of the work, other than one of my macros that I will be testing shortly that converts from numeric to ISO8601 format.

 

The existing macro allowed for truncation but not omitted sections replaced by -, both of which are allowed by ISO8601. In addition to those human readable variants SAS like to store ISO8601 informatted data in an encoded fashion using a mix of decimal and hex. Definitely both the human readable options are valid input, they both follow the specification. As SAS claims that its encoded format is extended ISO8601, I believe I should consider this to be valid input because SAS considers it to match that style and it maps 1 to 1 with valid extended ISO8601 format. In addition, there is a fairly chaotic system for converting data in SDTM that is out of my control so it is plausible that data could reach this macro in that encoded format, given it is how SAS claims ISO8601 should be handled, for very odd reasons. 

 

For this macro at least, it is definitely easier to find the correct output in the human readable form, so I want to be able to check if it is in the encoded format so I can convert it before applying the macros logic. Currently planning on moving valid ISO8601 date verification to a new macro but that will also need to handle the encoded informat, possibly I can do that with a clean regex.

Tom
Super User Tom
Super User

Are you asking to do validation of an SDTM dataset?  Aren't there already tools available to do that?  For example see this article:  https://support.sas.com/resources/papers/proceedings17/0836-2017.pdf

Why not just run those?

Tom
Super User Tom
Super User

In both of your examples there is nothing stored in the actual value of DT that indicates the value was created by using the $N8601E informat.  So if there is no informat specification attached to the variable there is nothing for VINFORMAT() function to return.

 

FORMAT in SAS has a specific meaning that is different than the way you are using the word.  In SAS a format is a tool for converting values into text.  So it is used when printing the value of variables.  It has nothing to do with how the values in the variable are stored or how they are created (other than that the format only works properly with the values it knows how to display.)

 

You can ATTACH a FORMAT to a variable so that SAS will use it by default.  Or you can request to use a format for a particular PROC step.  Or use a format with the PUT (or PUTN or PUTC) function.

 

The same thing applies with INFORMATs, which are instructions for how to convert text into values.  If you want to ATTACH an informat to a variable you use the INFORMAT statement (or INFORMAT= option of ATTRIB statement or PROC SQL select statement.).

 

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 17 replies
  • 1115 views
  • 21 likes
  • 6 in conversation