Clinwright Public work of Clinwright examples · free Start free

ADCM

Concomitant Medications Analysis Dataset

OCCURRENCE DATA STRUCTURE · one record per subject per concomitant medication · keys STUDYID, USUBJID, CMSEQ

Variables

VariableLabelTypeLengthDerivation
STUDYIDStudy IdentifiertextPredecessor ADSL.STUDYID
SITEIDStudy Site IdentifiertextPredecessor ADSL.SITEID
USUBJIDUnique Subject IdentifiertextPredecessor ADSL.USUBJID
SUBJIDSubject Identifier for the StudytextPredecessor ADSL.SUBJID
TRTAActual TreatmenttextPredecessor ADSL.TRT01A
TRTANActual Treatment (N)integer8Predecessor ADSL.TRT01AN
AGEAgeinteger8Predecessor ADSL.AGE
AGEGR1Pooled Age Group 1textPredecessor ADSL.AGEGR1
SEXSextextPredecessor ADSL.SEX
RACERacetextPredecessor ADSL.RACE
SAFFLSafety Population FlagtextPredecessor ADSL.SAFFL
TRTSDTDate of First Exposure to Treatmentinteger8Predecessor ADSL.TRTSDT
TRTEDTDate of Last Exposure to Treatmentinteger8Predecessor ADSL.TRTEDT
CMSEQSequence Numberinteger8Predecessor CM.CMSEQ
CMTRTReported Name of Drug, Med, or TherapytextPredecessor CM.CMTRT
CMDECODStandardized Medication NametextPredecessor CM.CMDECOD
CMCLASMedication ClasstextPredecessor CM.CMCLAS
CMINDCIndicationtextPredecessor CM.CMINDC
CMDOSEDose per Administrationfloat8Predecessor CM.CMDOSE
CMDOSUDose UnitstextPredecessor CM.CMDOSU
CMDOSFRQDosing Frequency per IntervaltextPredecessor CM.CMDOSFRQ
CMROUTERoute of AdministrationtextPredecessor CM.CMROUTE
CMSTDTCStart Date/Time of MedicationtextPredecessor CM.CMSTDTC
CMENDTCEnd Date/Time of MedicationtextPredecessor CM.CMENDTC
ASTDTAnalysis Start Dateinteger8CM.CMSTDTC converted to a numeric SAS date.
ASTDYAnalysis Start Relative Dayinteger8ASTDT - TRTSDT + 1 if ASTDT is on or after TRTSDT, else ASTDT - TRTSDT.
AENDTAnalysis End Dateinteger8CM.CMENDTC converted to a numeric SAS date.
AENDYAnalysis End Relative Dayinteger8AENDT - TRTSDT + 1 if AENDT is on or after TRTSDT, else AENDT - TRTSDT.
ONTRTFLOn Treatment Record FlagtextY if TRTSDT <= ASTDT <= TRTEDT.

Program adcm.sas

Version 1, written from Clinwright's patterns, 2026-10-17, checks passed.

/*==== 00-header ====*/
/*----------------------------------------------------------------------------
  Data set : ADCM (Concomitant Medications Analysis Dataset)
  Reporting effort : CSR
  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 CM records, with the subject's TRTSDT, TRTEDT, STUDYID, SITEID, USUBJID, SUBJID, TRT01A, TRT01AN, AGE, AGEGR1, SEX, RACE, SAFFL from ADSL. */
proc sort data=sdtm.cm(keep=studyid usubjid cmseq cmtrt cmdecod cmindc cmclas cmdose cmdosu cmdosfrq cmroute cmstdtc cmendtc) out=work._ds; by usubjid; run;
proc sort data=adam.adsl(keep=usubjid trtsdt trtedt studyid siteid usubjid subjid trt01a trt01an age agegr1 sex race saffl) out=work._adsl; by usubjid; run;
data work._ds;
  merge work._ds(in=_in) work._adsl;
  by usubjid;
  if _in;
  length trta $200;
  trta = trt01a;
  trtan = trt01an;
run;

/*==== 30-timing ====*/
/* ASTDT: CM.CMSTDTC as a SAS date. */
data work._ds;
  set work._ds;
  length _dtc $10;
  _dtc = cmstdtc; /* (its first 10 characters: SUBSTR would complain of a shorter variable) */
  if length(_dtc) = 10 then astdt = input(_dtc, ?? yymmdd10.);

  format astdt date9.;
  drop _dtc;
run;

/* ASTDY: day of ASTDT relative to TRTSDT; no day 0. */
data work._ds;
  set work._ds;
  if nmiss(astdt, trtsdt) = 0 then astdy = astdt - trtsdt + (astdt >= trtsdt);
run;

/* AENDT: CM.CMENDTC as a SAS date. */
data work._ds;
  set work._ds;
  length _dtc $10;
  _dtc = cmendtc; /* (its first 10 characters: SUBSTR would complain of a shorter variable) */
  if length(_dtc) = 10 then aendt = input(_dtc, ?? yymmdd10.);

  format aendt date9.;
  drop _dtc;
run;

/* AENDY: day of AENDT relative to TRTSDT; no day 0. */
data work._ds;
  set work._ds;
  if nmiss(aendt, trtsdt) = 0 then aendy = aendt - trtsdt + (aendt >= trtsdt);
run;

/*==== 60-flags ====*/
/* ONTRTFL: Y if TRTSDT <= ASTDT <= TRTEDT + 0. */
data work._ds;
  set work._ds;
  length ontrtfl $1;
  if . < trtsdt <= astdt and astdt <= trtedt + 0 then ontrtfl = 'Y';
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; %let _len15 = 1; %let _len16 = 1; %let _len17 = 1; %let _len18 = 1; %let _len19 = 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, 'SITEID') > 0 then do; _ren = catx(' ', _ren, 'SITEID=_rz2'); _asg = catx(' ', _asg, 'SITEID = _rz2;');
    _siz = catx(' ', _siz, '_len2 = max(_len2, lengthn(SITEID));'); end;
  if varnum(_dsid, 'USUBJID') > 0 then do; _ren = catx(' ', _ren, 'USUBJID=_rz3'); _asg = catx(' ', _asg, 'USUBJID = _rz3;');
    _siz = catx(' ', _siz, '_len3 = max(_len3, lengthn(USUBJID));'); end;
  if varnum(_dsid, 'SUBJID') > 0 then do; _ren = catx(' ', _ren, 'SUBJID=_rz4'); _asg = catx(' ', _asg, 'SUBJID = _rz4;');
    _siz = catx(' ', _siz, '_len4 = max(_len4, lengthn(SUBJID));'); end;
  if varnum(_dsid, 'TRTA') > 0 then do; _ren = catx(' ', _ren, 'TRTA=_rz5'); _asg = catx(' ', _asg, 'TRTA = _rz5;');
    _siz = catx(' ', _siz, '_len5 = max(_len5, lengthn(TRTA));'); end;
  if varnum(_dsid, 'AGEGR1') > 0 then do; _ren = catx(' ', _ren, 'AGEGR1=_rz6'); _asg = catx(' ', _asg, 'AGEGR1 = _rz6;');
    _siz = catx(' ', _siz, '_len6 = max(_len6, lengthn(AGEGR1));'); end;
  if varnum(_dsid, 'SEX') > 0 then do; _ren = catx(' ', _ren, 'SEX=_rz7'); _asg = catx(' ', _asg, 'SEX = _rz7;');
    _siz = catx(' ', _siz, '_len7 = max(_len7, lengthn(SEX));'); end;
  if varnum(_dsid, 'RACE') > 0 then do; _ren = catx(' ', _ren, 'RACE=_rz8'); _asg = catx(' ', _asg, 'RACE = _rz8;');
    _siz = catx(' ', _siz, '_len8 = max(_len8, lengthn(RACE));'); end;
  if varnum(_dsid, 'SAFFL') > 0 then do; _ren = catx(' ', _ren, 'SAFFL=_rz9'); _asg = catx(' ', _asg, 'SAFFL = _rz9;');
    _siz = catx(' ', _siz, '_len9 = max(_len9, lengthn(SAFFL));'); end;
  if varnum(_dsid, 'CMTRT') > 0 then do; _ren = catx(' ', _ren, 'CMTRT=_rz10'); _asg = catx(' ', _asg, 'CMTRT = _rz10;');
    _siz = catx(' ', _siz, '_len10 = max(_len10, lengthn(CMTRT));'); end;
  if varnum(_dsid, 'CMDECOD') > 0 then do; _ren = catx(' ', _ren, 'CMDECOD=_rz11'); _asg = catx(' ', _asg, 'CMDECOD = _rz11;');
    _siz = catx(' ', _siz, '_len11 = max(_len11, lengthn(CMDECOD));'); end;
  if varnum(_dsid, 'CMCLAS') > 0 then do; _ren = catx(' ', _ren, 'CMCLAS=_rz12'); _asg = catx(' ', _asg, 'CMCLAS = _rz12;');
    _siz = catx(' ', _siz, '_len12 = max(_len12, lengthn(CMCLAS));'); end;
  if varnum(_dsid, 'CMINDC') > 0 then do; _ren = catx(' ', _ren, 'CMINDC=_rz13'); _asg = catx(' ', _asg, 'CMINDC = _rz13;');
    _siz = catx(' ', _siz, '_len13 = max(_len13, lengthn(CMINDC));'); end;
  if varnum(_dsid, 'CMDOSU') > 0 then do; _ren = catx(' ', _ren, 'CMDOSU=_rz14'); _asg = catx(' ', _asg, 'CMDOSU = _rz14;');
    _siz = catx(' ', _siz, '_len14 = max(_len14, lengthn(CMDOSU));'); end;
  if varnum(_dsid, 'CMDOSFRQ') > 0 then do; _ren = catx(' ', _ren, 'CMDOSFRQ=_rz15'); _asg = catx(' ', _asg, 'CMDOSFRQ = _rz15;');
    _siz = catx(' ', _siz, '_len15 = max(_len15, lengthn(CMDOSFRQ));'); end;
  if varnum(_dsid, 'CMROUTE') > 0 then do; _ren = catx(' ', _ren, 'CMROUTE=_rz16'); _asg = catx(' ', _asg, 'CMROUTE = _rz16;');
    _siz = catx(' ', _siz, '_len16 = max(_len16, lengthn(CMROUTE));'); end;
  if varnum(_dsid, 'CMSTDTC') > 0 then do; _ren = catx(' ', _ren, 'CMSTDTC=_rz17'); _asg = catx(' ', _asg, 'CMSTDTC = _rz17;');
    _siz = catx(' ', _siz, '_len17 = max(_len17, lengthn(CMSTDTC));'); end;
  if varnum(_dsid, 'CMENDTC') > 0 then do; _ren = catx(' ', _ren, 'CMENDTC=_rz18'); _asg = catx(' ', _asg, 'CMENDTC = _rz18;');
    _siz = catx(' ', _siz, '_len18 = max(_len18, lengthn(CMENDTC));'); end;
  if varnum(_dsid, 'ONTRTFL') > 0 then do; _ren = catx(' ', _ren, 'ONTRTFL=_rz19'); _asg = catx(' ', _asg, 'ONTRTFL = _rz19;');
    _siz = catx(' ', _siz, '_len19 = max(_len19, lengthn(ONTRTFL));'); 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 _len15 1 _len16 1 _len17 1 _len18 1 _len19 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);
    call symputx('_len15', _len15);
    call symputx('_len16', _len16);
    call symputx('_len17', _len17);
    call symputx('_len18', _len18);
    call symputx('_len19', _len19);
  end;
run;
data adam.adcm(label="Concomitant Medications Analysis Dataset");
  attrib
    STUDYID  length=$&_len1 label="Study Identifier"
    SITEID   length=$&_len2 label="Study Site Identifier"
    USUBJID  length=$&_len3 label="Unique Subject Identifier"
    SUBJID   length=$&_len4 label="Subject Identifier for the Study"
    TRTA     length=$&_len5 label="Actual Treatment"
    TRTAN    length=8 label="Actual Treatment (N)"
    AGE      length=8 label="Age"
    AGEGR1   length=$&_len6 label="Pooled Age Group 1"
    SEX      length=$&_len7 label="Sex"
    RACE     length=$&_len8 label="Race"
    SAFFL    length=$&_len9 label="Safety Population Flag"
    TRTSDT   length=8 label="Date of First Exposure to Treatment" format=DATE9.
    TRTEDT   length=8 label="Date of Last Exposure to Treatment" format=DATE9.
    CMSEQ    length=8 label="Sequence Number"
    CMTRT    length=$&_len10 label="Reported Name of Drug, Med, or Therapy"
    CMDECOD  length=$&_len11 label="Standardized Medication Name"
    CMCLAS   length=$&_len12 label="Medication Class"
    CMINDC   length=$&_len13 label="Indication"
    CMDOSE   length=8 label="Dose per Administration"
    CMDOSU   length=$&_len14 label="Dose Units"
    CMDOSFRQ length=$&_len15 label="Dosing Frequency per Interval"
    CMROUTE  length=$&_len16 label="Route of Administration"
    CMSTDTC  length=$&_len17 label="Start Date/Time of Medication"
    CMENDTC  length=$&_len18 label="End Date/Time of Medication"
    ASTDT    length=8 label="Analysis Start Date" format=DATE9.
    ASTDY    length=8 label="Analysis Start Relative Day"
    AENDT    length=8 label="Analysis End Date" format=DATE9.
    AENDY    length=8 label="Analysis End Relative Day"
    ONTRTFL  length=$&_len19 label="On Treatment Record Flag"
  ;
  set work._final&_ren;
  &_asg
  keep STUDYID SITEID USUBJID SUBJID TRTA TRTAN AGE AGEGR1 SEX RACE SAFFL TRTSDT TRTEDT CMSEQ CMTRT CMDECOD CMCLAS CMINDC CMDOSE CMDOSU CMDOSFRQ CMROUTE CMSTDTC CMENDTC ASTDT ASTDY AENDT AENDY ONTRTFL;
run;
proc sort data=adam.adcm; by STUDYID USUBJID CMSEQ; run;

Data (first 20 of 7,510 records, uploaded)

STUDYIDSITEIDUSUBJIDSUBJIDTRTATRTANAGEAGEGR1SEXRACESAFFLTRTSDTTRTEDTCMSEQCMTRTCMDECODCMCLASCMINDCCMDOSECMDOSUCMDOSFRQCMROUTECMSTDTCCMENDTCASTDTASTDYAENDTAENDYONTRTFL
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-021ASPIRINACETYLSALICYLIC ACIDNERVOUS SYSTEM1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-022TYLENOLUNCODEDUNCODED1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-023PREMARINESTROGENS CONJUGATEDGENITO URINARY SYSTEM AND SEX HORMONESPROPHYLAXIS OR NON-THERAPEUTIC USE0.625mgQDORAL2006
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-024CALCIUMCALCIUMALIMENTARY TRACT AND METABOLISMPROPHYLAXIS OR NON-THERAPEUTIC USE1TABLETQDORAL2013
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-025ASPIRINACETYLSALICYLIC ACIDNERVOUS SYSTEM1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-026TYLENOLUNCODEDUNCODED1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-027PREMARINESTROGENS CONJUGATEDGENITO URINARY SYSTEM AND SEX HORMONESPROPHYLAXIS OR NON-THERAPEUTIC USE0.625mgQDORAL2006
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-028CALCIUMCALCIUMALIMENTARY TRACT AND METABOLISMPROPHYLAXIS OR NON-THERAPEUTIC USE1TABLETQDORAL2013
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-029ASPIRINACETYLSALICYLIC ACIDNERVOUS SYSTEM1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0210TYLENOLUNCODEDUNCODED1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0211PREMARINESTROGENS CONJUGATEDGENITO URINARY SYSTEM AND SEX HORMONESPROPHYLAXIS OR NON-THERAPEUTIC USE0.625mgQDORAL2006
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0212CALCIUMCALCIUMALIMENTARY TRACT AND METABOLISMPROPHYLAXIS OR NON-THERAPEUTIC USE1TABLETQDORAL2013
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0213ASPIRINACETYLSALICYLIC ACIDNERVOUS SYSTEM1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0214TYLENOLUNCODEDUNCODED1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0215PREMARINESTROGENS CONJUGATEDGENITO URINARY SYSTEM AND SEX HORMONESPROPHYLAXIS OR NON-THERAPEUTIC USE0.625mgQDORAL2006
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0216CALCIUMCALCIUMALIMENTARY TRACT AND METABOLISMPROPHYLAXIS OR NON-THERAPEUTIC USE1TABLETQDORAL2013
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0217NEOSPORIN /USA/UNCODEDUNCODED1VIALPRNTOPICAL2014-01-032014-01-032Y
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0218ASPIRINACETYLSALICYLIC ACIDNERVOUS SYSTEM1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0219TYLENOLUNCODEDUNCODED1TABLETPRNORAL2003
CDISCPILOT0170101-701-10151015Placebo063<65FWHITEY2014-01-022014-07-0220PREMARINESTROGENS CONJUGATEDGENITO URINARY SYSTEM AND SEX HORMONESPROPHYLAXIS OR NON-THERAPEUTIC USE0.625mgQDORAL2006