Convert CPRD special date formats to IDate

Share:

Description

Converts GEN_SDC and YYYYMMDD dates in the additional data area of the CPRD clinical and test tables from the CPRD GOLD format to IDate. The YYYYMMDD format can be used for imprecise dates where the day or month are unknown; these are filled in using default values.

Usage

1
2
3
4
GEN_SDCtoDate(GEN_SDC)
YYYYMMDDtoDate(YYYYMMDD, default_day_month = 15, 
    default_month_year = 7, default_day_month_year = 1, 
    valid_lower_year = 1800, valid_upper_year = 2050)

Arguments

GEN_SDC

a numeric or integer vector of dates coded in GEN_SDC format.

YYYYMMDD

a numeric or integer vector of dates coded in YYYYMMDD format.

default_day_month

default day of the month to use for dates in year-month format.

default_month_year

default month of the year to use if only the year is given.

default_day_month_year

default day of the month to be used if only the year is given.

valid_lower_year

lower year limit for valid dates.

valid_upper_year

upper year limit for valid dates.

Details

The GEN_SDC date in dd/mm/yyyy format can be obtained as follows:

0 An invalid / missing date
2 A date greater than 31/12/2014
3 A date earlier than 01/01/1800
All other values number of days between the date and the 31/12/2014 offset by 10.

Example: A value of 4027 decodes to the date 01/01/2004. 4027-10 = 4017 days prior to the date 31/12/2014 is the date 01/01/2004

The YYYYMMDD format is an integer with 4-8 digits specifying the year with optional month and day, ie. YYYY, YYYYMM or YYYYMMDD.

Example: A value of 2001 is the year 2001, a value of 2000107 is July 2001 and 20010706 is 6 July 2001.

Value

An integer vector of dates in IDate format. Dates after 31/12/2014 or before 01/01/1800 (GEN_SDC) and any dates outside the range of valid_lower_year and valid_upper_year are converted to missing (NA).

References

Puri S. GPRD Gold Data Dictionary, Version 1.1. GPRD, MHRA, UK.

See Also

textToDate, convertDates

Examples

1
2
3
##
GEN_SDCtoDate(c(0, 1, 2, 3, 4027))
YYYYMMDDtoDate(c(1987,198701, 19870507))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.