Example: bachelor of science

Imputing ISO8601 Dates From Character Variables …

Paper FC06 Imputing ISO8601 Dates From Character Variables Containing Partial Dates John R. Gerlach, MaxisIT Abstract Assume that there is an initiative to include legacy studies into a database such that the original data are converted into SDTM domains in compliance with CDISC standards. One aspect of this effort involves date Variables that must follow ISO8601 rules. This sub-task would be easy if the data were stored in SAS data sets and, specifically, the Dates were stored as SAS date Variables . Unfortunately, the plethora of data is stored mostly as raw text files. Moreover, Dates are stored as Character Variables in various formats ( , mmddyyyy, yyyymmdd).

Paper FC06 Imputing ISO8601 Dates From Character Variables Containing Partial Dates John R. Gerlach, MaxisIT Abstract Assume that there is an initiative to include legacy studies into a database such that the original data are converted

Tags:

  Dates from character variables

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Imputing ISO8601 Dates From Character Variables …

1 Paper FC06 Imputing ISO8601 Dates From Character Variables Containing Partial Dates John R. Gerlach, MaxisIT Abstract Assume that there is an initiative to include legacy studies into a database such that the original data are converted into SDTM domains in compliance with CDISC standards. One aspect of this effort involves date Variables that must follow ISO8601 rules. This sub-task would be easy if the data were stored in SAS data sets and, specifically, the Dates were stored as SAS date Variables . Unfortunately, the plethora of data is stored mostly as raw text files. Moreover, Dates are stored as Character Variables in various formats ( , mmddyyyy, yyyymmdd).

2 Even worse, the date Variables contain partial Dates and, perhaps, bogus values. This paper explains a SAS macro that imputes ISO8601 Dates from Character Variables containing even partial Dates . Introduction The International Standard ISO 8601 specifies numeric representations of date and time. This standard is based on the Gregorian calendar (introduced in 1582) for Dates and the 24-hour clock for time. All ISO compliant Dates and times are written with the largest time units given first, from left to right, that is: year, month, week, day, hour, minute, and second. This standard offers representations for the following time elements: date, time of day, Coordinated Universal Time (UTC), local time with offset to UTC, date and time, time intervals, and recurring time intervals.

3 Representations can be in one of two formats: a basic format showing only the date/time elements, such as 20060522, or extended format, such as 2006-05-22, both representing May 22, 2006. Hyphens are used sometimes to denote missing components. The CDISC / SDTM standard includes the ISO 8601 standard for those Variables representing Dates and time. Consider the partial list of SDTM Variables denoting time elements: RFSTDTC Subject Reference Start Date/Time (Demographic domain) AESTDTC Start Date/Time of an adverse event AEENDTC End Date/Time of an adverse event AEDUR Duration of an adverse event LBDTC Date/Time of specimen collection PEDTC Date/Time of examination Suffice it to say that time elements are an important component of SDTM data sets.

4 However, for this discussion, this paper will address only Dates , not time elements. If this vital information were stored as SAS date Variables , it would be easy to populate such Variables using SAS, Version , specifically the IS8601DA for date Variables and IS8601DT and IS8601DN for date-time Variables . The IS8601DT format writes a date-time value ( , 2006-05-22T09:30:00:00) and the IS8601DT writes a date value using a date-time variable, similar to the IS8601DA format for date Variables . These formats write values in complete representation, which includes seconds for the IS8601DT format, which may not be desirable.

5 Also noteworthy, these same formats do not allow a truncation of a value using a smaller width, which prompts a nasty error message, such as: Error: Format IS8601DT specified with width out of range. Unfortunately, the aforementioned legacy data contains Dates that are stored as Character Variables often consisting of incomplete Dates . Thus, the SAS-supplied formats are not immediately useful for the task of generating ISO8601 compliant Dates for SDTM data sets. Imputation Rules In order to impute ISO compliant Dates from Character Variables , it is important to consider the possible natural formats of the Dates found in the legacy data.

6 For this discussion, three natural date formats are considered: MMDDYYYY ( , 05/22/2006); DDMONYYYY ( , 22 MAY2006); and, YYYYMMDD ( , 20060522). It is assumed that these Dates might be manifested in several ways, as illustrated in the following table. The original values are listed on the left side of each date-type column; whereas, the right side denotes the imputed values written in year, month, day order. -------- MMDDYYYY --------- ------- DDMONYYYY ------- ------- YYYYYMMDD -------- 01012005 2005 01 01 01 JAN2005 2005 JAN 01 20050101 2005 01 01 01/01/2005 2005 01 01 01 JAN2005 2005 JAN 01 2005/01/01 2005 01 01 01-01-2005 2005 01 01 01 JAN2005 2005 JAN 01 2005-01-01 2005 01 01 01- -2005 2005 01 01 JAN2005 2005 JAN 01 2005- -01 2005 01 -01-2005 2005 01 01 JAN2005 2005 JAN 01 2005-01- 2005 01 2005

7 01 01 01 JAN2005 2005 JAN 01 2005 01 01 01 2005 2005 01 01 JAN2005 2005 JAN 01 2005 01 2005 01 01 2005 2005 01 JAN2005 2005 JAN 200501 2005 01 012005 2005 01 01 2005 2005 01 2005 01 2005 01 012005 2005 01 01 JAN JAN 01 2005 01 2005 01 As stated already, the date Variables might contain incomplete Dates . Moreover, the date Variables might contain other characters, such as a virgule, dash, blank, or period ( , 01/01/2005).

8 The utility must be robust enough to deal with the diverse values, as well as consider the opportunity to impute partial Dates in a hierarchical fashion. The table above documents the proposed imputations. Also, keep in mind that the imputed values will be used accordingly, meaning that a date component might not be used because there is no higher-level date component associated with it. The Utility The %isodate macro is designed to process a SAS data set containing one or more Character Variables that contain full or partial Dates having the form DDMMYYYY ( , 22052006), DDMONYYYY ( , 22 MAY2006), or MMDDYYYY ( , 05222006).

9 The macro definition contains five parameters including one keyword parameter denoting a default date format. The positional parameters are: IDSN Input data set ODSN Output data set IVAR Input Character variable containing full or partial Dates OVAR Output Character variable containing ISO8601 Dates Basically, the macro processes a SAS data set using, a designated Character variable, and creates a new data set containing the original variable plus a new variable containing ISO8601 compliant Dates . In order to accomplish this task, the macro considers one of three possible natural date formats and applies it to the Character variable in order to impute its ISO equivalent.

10 Using one of the aforementioned natural date formats, denoted the keyword parameter FMT, the macro assigns the appropriate SAS-supplied input format, which is used to read the values of the Character variable. Thus, for example, if the keyword parameter FMT is assigned the value DDMONYYYY, then the same local macro variable is assigned the value date9, the respective SAS input format. For the formats MMDDYYYY and YYYYMMDD, the FMT variable is assigned the SAS input formats mmddyy10 and yymmdd10, respectively. Since one of the proposed formats includes an abbreviation for the month, a format is created to convert that component into a two digit number.