ADMH
Medical History Analysis Dataset
OCCURRENCE DATA STRUCTURE · one record per subject per medical history term · keys STUDYID, USUBJID, MHSEQ
Variables
| Variable | Label | Type | Length | Derivation |
|---|---|---|---|---|
STUDYID | Study Identifier | text | Predecessor MH.STUDYID | |
USUBJID | Unique Subject Identifier | text | Predecessor MH.USUBJID | |
SUBJID | Subject Identifier for the Study | text | Predecessor ADSL.SUBJID | |
SITEID | Study Site Identifier | text | Predecessor ADSL.SITEID | |
AGE | Age | integer | 8 | Predecessor ADSL.AGE |
SEX | Sex | text | Predecessor ADSL.SEX | |
RACE | Race | text | Predecessor ADSL.RACE | |
SAFFL | Safety Population Flag | text | Predecessor ADSL.SAFFL | |
TRT01P | Planned Treatment for Period 01 | text | Predecessor ADSL.TRT01P | |
TRT01A | Actual Treatment for Period 01 | text | Predecessor ADSL.TRT01A | |
TRTSDT | Date of First Exposure to Treatment | integer | 8 | Predecessor ADSL.TRTSDT |
MHSEQ | Sequence Number | integer | 8 | Predecessor MH.MHSEQ |
MHTERM | Reported Term for the Medical History | text | Predecessor MH.MHTERM | |
MHDECOD | Dictionary-Derived Term | text | Predecessor MH.MHDECOD | |
MHBODSYS | Body System or Organ Class | text | Predecessor MH.MHBODSYS | |
MHSTDTC | Start Date/Time of Medical History Event | text | Predecessor MH.MHSTDTC | |
ASTDT | Analysis Start Date | integer | 8 | MH.MHSTDTC converted to a numeric SAS date; a partial date is imputed to the first day (of the month, or of the year when the month is missing too). |
ASTDTF | Analysis Start Date Imputation Flag | text | The level of imputation of ASTDT from MH.MHSTDTC: D when the day was imputed, M when the month and day were. |
Program admh.sas
Version 1, written from Clinwright's patterns, 2026-10-17, checks passed.
/*==== 00-header ====*/
/*----------------------------------------------------------------------------
Data set : ADMH (Medical History Analysis Dataset)
Reporting effort : CSR
SDTM : MH
ADaM : ADSL
The header and the finalize step follow from the specification.
----------------------------------------------------------------------------*/
libname sdtm "/work/sdtm" access=readonly;
libname adam "/work/adam";
options validvarname=upcase nofmterr msglevel=i;
/*==== 10-inputs ====*/
/* The MH records, with the subject's TRTSDT, TRTEDT, SUBJID, SITEID, AGE, SEX, RACE, SAFFL, TRT01P, TRT01A from ADSL. */
proc sort data=sdtm.mh(keep=studyid usubjid mhseq mhterm mhdecod mhbodsys mhstdtc) out=work._ds; by usubjid; run;
proc sort data=adam.adsl(keep=usubjid trtsdt trtedt subjid siteid age sex race saffl trt01p trt01a) out=work._adsl; by usubjid; run;
data work._ds;
merge work._ds(in=_in) work._adsl;
by usubjid;
if _in;
run;
/*==== 30-timing ====*/
/* ASTDT: MH.MHSTDTC as a SAS date; a date without its day (or month) takes the first one. */
data work._ds;
set work._ds;
length _dtc $10;
_dtc = mhstdtc; /* (its first 10 characters: SUBSTR would complain of a shorter variable) */
if length(_dtc) = 10 then astdt = input(_dtc, ?? yymmdd10.);
else if length(_dtc) = 7 then do; /* yyyy-mm */
astdt = input(cats(_dtc, '-01'), ?? yymmdd10.);
end;
else if length(_dtc) = 4 then do; /* yyyy */
astdt = mdy(1, 1, input(_dtc, ?? 4.));
end;
format astdt date9.;
drop _dtc;
run;
/* ASTDTF: what of ASTDT was imputed from MH.MHSTDTC (set where ASTDT is imputed; see LSP-TIMING-DT). */
data work._ds;
set work._ds;
length astdtf $1;
if astdt > . then select (length(substr(mhstdtc, 1, 10)));
when (10) astdtf = '';
when (7) astdtf = 'D';
when (4) astdtf = 'M';
otherwise astdtf = '';
end;
run;
/*==== 89-final ====*/
/* The data set as derived; the finalize step keeps the specification's variables. */
data work._final;
set work._ds;
run;
/*==== 90-finalize ====*/
/* 90-finalize: from the specification; the variables, their order and attributes are not changed here. */
/* The text variables the specification gives no length: as long as their longest value (at least 1). */
%let _len1 = 1; %let _len2 = 1; %let _len3 = 1; %let _len4 = 1; %let _len5 = 1; %let _len6 = 1; %let _len7 = 1; %let _len8 = 1; %let _len9 = 1; %let _len10 = 1; %let _len11 = 1; %let _len12 = 1; %let _len13 = 1; %let _len14 = 1;
data _null_;
length _ren _asg _siz $32767;
_dsid = open('work._final');
if varnum(_dsid, 'STUDYID') > 0 then do; _ren = catx(' ', _ren, 'STUDYID=_rz1'); _asg = catx(' ', _asg, 'STUDYID = _rz1;');
_siz = catx(' ', _siz, '_len1 = max(_len1, lengthn(STUDYID));'); end;
if varnum(_dsid, 'USUBJID') > 0 then do; _ren = catx(' ', _ren, 'USUBJID=_rz2'); _asg = catx(' ', _asg, 'USUBJID = _rz2;');
_siz = catx(' ', _siz, '_len2 = max(_len2, lengthn(USUBJID));'); end;
if varnum(_dsid, 'SUBJID') > 0 then do; _ren = catx(' ', _ren, 'SUBJID=_rz3'); _asg = catx(' ', _asg, 'SUBJID = _rz3;');
_siz = catx(' ', _siz, '_len3 = max(_len3, lengthn(SUBJID));'); end;
if varnum(_dsid, 'SITEID') > 0 then do; _ren = catx(' ', _ren, 'SITEID=_rz4'); _asg = catx(' ', _asg, 'SITEID = _rz4;');
_siz = catx(' ', _siz, '_len4 = max(_len4, lengthn(SITEID));'); end;
if varnum(_dsid, 'SEX') > 0 then do; _ren = catx(' ', _ren, 'SEX=_rz5'); _asg = catx(' ', _asg, 'SEX = _rz5;');
_siz = catx(' ', _siz, '_len5 = max(_len5, lengthn(SEX));'); end;
if varnum(_dsid, 'RACE') > 0 then do; _ren = catx(' ', _ren, 'RACE=_rz6'); _asg = catx(' ', _asg, 'RACE = _rz6;');
_siz = catx(' ', _siz, '_len6 = max(_len6, lengthn(RACE));'); end;
if varnum(_dsid, 'SAFFL') > 0 then do; _ren = catx(' ', _ren, 'SAFFL=_rz7'); _asg = catx(' ', _asg, 'SAFFL = _rz7;');
_siz = catx(' ', _siz, '_len7 = max(_len7, lengthn(SAFFL));'); end;
if varnum(_dsid, 'TRT01P') > 0 then do; _ren = catx(' ', _ren, 'TRT01P=_rz8'); _asg = catx(' ', _asg, 'TRT01P = _rz8;');
_siz = catx(' ', _siz, '_len8 = max(_len8, lengthn(TRT01P));'); end;
if varnum(_dsid, 'TRT01A') > 0 then do; _ren = catx(' ', _ren, 'TRT01A=_rz9'); _asg = catx(' ', _asg, 'TRT01A = _rz9;');
_siz = catx(' ', _siz, '_len9 = max(_len9, lengthn(TRT01A));'); end;
if varnum(_dsid, 'MHTERM') > 0 then do; _ren = catx(' ', _ren, 'MHTERM=_rz10'); _asg = catx(' ', _asg, 'MHTERM = _rz10;');
_siz = catx(' ', _siz, '_len10 = max(_len10, lengthn(MHTERM));'); end;
if varnum(_dsid, 'MHDECOD') > 0 then do; _ren = catx(' ', _ren, 'MHDECOD=_rz11'); _asg = catx(' ', _asg, 'MHDECOD = _rz11;');
_siz = catx(' ', _siz, '_len11 = max(_len11, lengthn(MHDECOD));'); end;
if varnum(_dsid, 'MHBODSYS') > 0 then do; _ren = catx(' ', _ren, 'MHBODSYS=_rz12'); _asg = catx(' ', _asg, 'MHBODSYS = _rz12;');
_siz = catx(' ', _siz, '_len12 = max(_len12, lengthn(MHBODSYS));'); end;
if varnum(_dsid, 'MHSTDTC') > 0 then do; _ren = catx(' ', _ren, 'MHSTDTC=_rz13'); _asg = catx(' ', _asg, 'MHSTDTC = _rz13;');
_siz = catx(' ', _siz, '_len13 = max(_len13, lengthn(MHSTDTC));'); end;
if varnum(_dsid, 'ASTDTF') > 0 then do; _ren = catx(' ', _ren, 'ASTDTF=_rz14'); _asg = catx(' ', _asg, 'ASTDTF = _rz14;');
_siz = catx(' ', _siz, '_len14 = max(_len14, lengthn(ASTDTF));'); end;
_rc = close(_dsid);
if _ren ne '' then _ren = cats('(rename=(', _ren, '))');
call symputx('_ren', _ren);
call symputx('_asg', _asg);
call symputx('_siz', _siz);
run;
data _null_;
set work._final end=_end;
retain _len1 1 _len2 1 _len3 1 _len4 1 _len5 1 _len6 1 _len7 1 _len8 1 _len9 1 _len10 1 _len11 1 _len12 1 _len13 1 _len14 1;
&_siz
if _end then do;
call symputx('_len1', _len1);
call symputx('_len2', _len2);
call symputx('_len3', _len3);
call symputx('_len4', _len4);
call symputx('_len5', _len5);
call symputx('_len6', _len6);
call symputx('_len7', _len7);
call symputx('_len8', _len8);
call symputx('_len9', _len9);
call symputx('_len10', _len10);
call symputx('_len11', _len11);
call symputx('_len12', _len12);
call symputx('_len13', _len13);
call symputx('_len14', _len14);
end;
run;
data adam.admh(label="Medical History Analysis Dataset");
attrib
STUDYID length=$&_len1 label="Study Identifier"
USUBJID length=$&_len2 label="Unique Subject Identifier"
SUBJID length=$&_len3 label="Subject Identifier for the Study"
SITEID length=$&_len4 label="Study Site Identifier"
AGE length=8 label="Age"
SEX length=$&_len5 label="Sex"
RACE length=$&_len6 label="Race"
SAFFL length=$&_len7 label="Safety Population Flag"
TRT01P length=$&_len8 label="Planned Treatment for Period 01"
TRT01A length=$&_len9 label="Actual Treatment for Period 01"
TRTSDT length=8 label="Date of First Exposure to Treatment" format=DATE9.
MHSEQ length=8 label="Sequence Number"
MHTERM length=$&_len10 label="Reported Term for the Medical History"
MHDECOD length=$&_len11 label="Dictionary-Derived Term"
MHBODSYS length=$&_len12 label="Body System or Organ Class"
MHSTDTC length=$&_len13 label="Start Date/Time of Medical History Event"
ASTDT length=8 label="Analysis Start Date" format=DATE9.
ASTDTF length=$&_len14 label="Analysis Start Date Imputation Flag"
;
set work._final&_ren;
&_asg
keep STUDYID USUBJID SUBJID SITEID AGE SEX RACE SAFFL TRT01P TRT01A TRTSDT MHSEQ MHTERM MHDECOD MHBODSYS MHSTDTC ASTDT ASTDTF;
run;
proc sort data=adam.admh; by STUDYID USUBJID MHSEQ; run;
Data (first 20 of 775 records, simulated)
| STUDYID | USUBJID | SUBJID | SITEID | AGE | SEX | RACE | SAFFL | TRT01P | TRT01A | TRTSDT | MHSEQ | MHTERM | MHDECOD | MHBODSYS | MHSTDTC | ASTDT | ASTDTF |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ONCO-EX | ONCO-EX-701001 | 1 | HYPOTHYROIDISM | Hypothyroidism | Endocrine disorders | 2007-08 | 2007-08-01 | D | |||||||||
| ONCO-EX | ONCO-EX-701001 | 2 | TYPE 2 DIABETES | Type 2 diabetes mellitus | Metabolism and nutrition disorders | 2018-10 | 2018-10-01 | D | |||||||||
| ONCO-EX | ONCO-EX-701003 | 701003 | 701 | 58 | M | WHITE | Y | Standard of Care | Standard of Care | 2022-03-17 | 1 | HIGH CHOLESTEROL | Hypercholesterolaemia | Metabolism and nutrition disorders | 2021-04 | 2021-04-01 | D |
| ONCO-EX | ONCO-EX-701004 | 701004 | 701 | 60 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-18 | 1 | APPENDECTOMY | Appendicectomy | Surgical and medical procedures | 2014-10 | 2014-10-01 | D |
| ONCO-EX | ONCO-EX-701005 | 701005 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-31 | 1 | DEPRESSION | Depression | Psychiatric disorders | 2021-06-24 | 2021-06-24 | |
| ONCO-EX | ONCO-EX-701005 | 701005 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-31 | 2 | HIGH CHOLESTEROL | Hypercholesterolaemia | Metabolism and nutrition disorders | 2011-12 | 2011-12-01 | D |
| ONCO-EX | ONCO-EX-701005 | 701005 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-31 | 3 | HYPERTENSION | Hypertension | Vascular disorders | 2009-10-22 | 2009-10-22 | |
| ONCO-EX | ONCO-EX-701005 | 701005 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-31 | 4 | INSOMNIA | Insomnia | Psychiatric disorders | 2005-01-04 | 2005-01-04 | |
| ONCO-EX | ONCO-EX-701005 | 701005 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-03-31 | 5 | TYPE 2 DIABETES | Type 2 diabetes mellitus | Metabolism and nutrition disorders | 2007-07 | 2007-07-01 | D |
| ONCO-EX | ONCO-EX-701006 | 1 | HYPERTENSION | Hypertension | Vascular disorders | 2006-06 | 2006-06-01 | D | |||||||||
| ONCO-EX | ONCO-EX-701007 | 701007 | 701 | 63 | M | WHITE | Y | Standard of Care | Standard of Care | 2022-04-19 | 1 | HYPERTENSION | Hypertension | Vascular disorders | 2011-05 | 2011-05-01 | D |
| ONCO-EX | ONCO-EX-701008 | 701008 | 701 | 54 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-04-26 | 1 | HIGH CHOLESTEROL | Hypercholesterolaemia | Metabolism and nutrition disorders | 2005-01 | 2005-01-01 | D |
| ONCO-EX | ONCO-EX-701008 | 701008 | 701 | 54 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-04-26 | 2 | HYPERTENSION | Hypertension | Vascular disorders | 2007-03 | 2007-03-01 | D |
| ONCO-EX | ONCO-EX-701008 | 701008 | 701 | 54 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-04-26 | 3 | HYSTERECTOMY | Hysterectomy | Surgical and medical procedures | 2012-03 | 2012-03-01 | D |
| ONCO-EX | ONCO-EX-701009 | 701009 | 701 | 58 | M | BLACK OR AFRICAN AMERICAN | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-04-18 | 1 | INSOMNIA | Insomnia | Psychiatric disorders | 2020-01-29 | 2020-01-29 | |
| ONCO-EX | ONCO-EX-701010 | 701010 | 701 | 64 | F | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-06-10 | 1 | APPENDECTOMY | Appendicectomy | Surgical and medical procedures | 2012-07 | 2012-07-01 | D |
| ONCO-EX | ONCO-EX-701010 | 701010 | 701 | 64 | F | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-06-10 | 2 | HYPERTENSION | Hypertension | Vascular disorders | 2015-12 | 2015-12-01 | D |
| ONCO-EX | ONCO-EX-701010 | 701010 | 701 | 64 | F | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-06-10 | 3 | INSOMNIA | Insomnia | Psychiatric disorders | 2017-10 | 2017-10-01 | D |
| ONCO-EX | ONCO-EX-701011 | 701011 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-06-16 | 1 | HIGH CHOLESTEROL | Hypercholesterolaemia | Metabolism and nutrition disorders | 2014-08 | 2014-08-01 | D |
| ONCO-EX | ONCO-EX-701011 | 701011 | 701 | 62 | M | WHITE | Y | Clinwrightinib 200 mg | Clinwrightinib 200 mg | 2022-06-16 | 2 | OSTEOARTHRITIS | Osteoarthritis | Musculoskeletal and connective tissue disorders | 2010-06-06 | 2010-06-06 |