DM
DM
DM
Study Number :
Study :
Program Name : DM
Purpose : Craeting Demographic Domain
Author : xxxxxxx
Date of Creation : DDMMM2023
Input Data :
Output : SDTM.DM
Assumptions : Taken from xxx
--------------------------------------------------------------------------
Modification History :
--------------------------------------------------------------------------
Modified By : xxxx
Modification Date :
Modification Description :
---------------------------------------------------------------------------*/
dm "log" clear;
options validvarname=upcase;
/* To bring Rawdatasets */
%let keepvar = studyid subjid usubjid rfstdtc rfxstdtc rfendtc rfxendtc rficdtc
rfpendtc invnam invid
age ageu sex race ethnic brthdtc dthdtc dthfl country arm
actarm armcd actarmcd dmdtc dmdy
siteid domain;
/* Format Creation */
proc format ;
value $sex_
"Female" = "F"
"Male" = "M"
;
value $race_
"White" = "WHITE"
;
value $ethnic_
"Hispanic" = "HISPANIC OR LATINO"
"Not Hispanic" = "NOT HISPANIC OR LATINO"
;
run;
/* Sorting macro*/
%macro sort(in=,out=,var=);
proc sort data=&in out = &out;
by &var;
run;
%mend sort;
data dm1(rename=(subjid_=subjid));
set dm(drop=siteid);
studyid = strip(project);
domain = "DM";
/* brthdtc =
put(input(substr(strip(put(brthdt,datetime22.)),1,9),date9.),is8601da.);*/
brthdtc = put(input(compress(brthdt_raw),date9.),is8601da.);
siteid = strip(sitenumber) ;
dmdtc =
put(input(substr(strip(put(recorddate,datetime22.)),1,9),date9.),is8601da.);
country = "USA";
drop subjid ;
run;
if first.usubjid;
rfstdtc =
put(input(substr(strip(put(exstdtc,datetime22.)),1,9),date9.),is8601da.)||"T"||
strip(exsttmc);
rfxstdtc = rfstdtc;
run;
if last.usubjid;
rfendtc =
put(input(substr(strip(put(exstdtc,datetime22.)),1,9),date9.),is8601da.)||"T"||
strip(exentmc);
rfxendtc = rfendtc;
run;
dthdtc = put(input(compress(deathdt_raw),date9.),is8601da.);
dthfl = "Y";
drop siteid;
run;
/* Deriving RFICDTC */
data ds_ic1;
set ds_ic;
rficdtc = put(input(compress(s_icdt_raw),date9.),is8601da.);
drop siteid;
run;
/* Deriving RFPENDTC */
%rep(ae,ae1,aestdt_raw);
%rep(ae,ae2,aeendt_raw);
%rep(antigs,antigs1,GSTM_RAW);
%rep(death,death_,DEATHDT_RAW);
%rep(ds_ic1,ds_ic2,S_PVERDT_RAW);
%rep(ex,ex_,EXSTDTC_RAW);
%rep(lb_pts,lb_pts1,LBDT_RAW);
%rep(sv,sv1,SVSTDT_RAW);
run;
proc sort data = rep;
by usubjid rfpendtc;
run;
data rep;
set rep;
by usubjid rfpendtc;
if last.usubjid ;
run;
data dm2;
merge dm1(in=a) start end death1 ds_ic1 rep;
by usubjid;
if a;
run;
data dm3;
merge dm2(in=a) inv_list;
by siteid;
if a;
invid = siteid;
rename pi_name = invnam;
run;
/* Screenfailure Information */
data dm4;
length armcd actarmcd $8. arm actarm $50. ;
merge dm3(in=a) scrfail(in=b);
by usubjid;
if a then do;
armcd = "1";
arm = "GS-6624";
actarmcd = "1";
actarm = "GS-6624";
end;
if b then do;
armcd = "SCRNFAIL";
arm = "Screen Failure";
actarmcd = "SCRNFAIL";
actarm = "Screen Failure";
end;
run;
/* DMDY */
data dm5(rename=(studyid_=studyid));
length studyid_ $20.;
set dm4;
rfstdtc_n = input(scan(rfstdtc,1,"T"),yymmdd10.);
dmdtc_n = input(dmdtc,yymmdd10.);
studyid_ = studyid;
drop studyid;
run;
data fin(label="Demographics");
set dm5;
keep &keepvar.;
run;
data sdtm.dm;
set fin;
run;
%let keepsupp = studyid usubjid rdomain idvar idvarval qnam qlabel qval qeval
qorig;
data supp;
length qnam $8. qlabel qorig $40. qval $200.;
set dm5;
rdomain = "DM";
idvar = "";
idvarval = "";
/* RACEOTH*/
QNAM = "RACEOTH";
qlabel = "Other race";
qval = strip(raceoth);
qorig = "CRF Page";
qeval = "";
if raceoth ne "" then output;
/* DEATHCAU*/
QNAM = "DEATHCAU";
qlabel = "Immediate Cause of Death";
qval = strip(deathcau);
qorig = "CRF Page";
qeval = "";
if qval ne "" then output;
/* SPONSOR ID*/
QNAM = "DMSPID";
qlabel = "Sponsor Identifier";
qval = strip(dmspid);
qorig = "Derived";
qeval = "";
if qval ne "" then output;
run;
attrib
STUDYID label ='Study Identifier' length = $14
RDOMAIN label ='Related Domain Abbreviation' length = $2
USUBJID label ='Unique Subject Identifier' length = $30
IDVAR label ='Identifying Variable' length = $8
IDVARVAL label ='Identifying Variable Value' length = $200
QNAM label ='Qualifier Variable Name' length = $8
QLABEL label ='Qualifier Variable Label' length = $40
QVAL label ='Data Value' length = $200
QORIG label ='Origin' length = $40
QEVAL label ='Evaluator' length = $40;
;
set supp;
keep &keepsupp.;
run;