You are on page 1of 6

proc sql; create table AE_1 (STUDYID char(100)"Study Identifier",DOMAIN char(100)"Domain Abbreviation",USUBJID char(100)"Unique Subject Identifier", AESEQ num

"Sequence Number",AEGRPID char(100)"Group ID",AEREFID char(100)"Reference ID",AESPID char(100)"Sponsor-Defined Identifier", AETERM char(100)"Reported Term for the Adverse Event",AEMODIFY char(100)"Modified Reported Term",AEDECOD char(100)"Dictionary-Derived Term",AECAT char(100)"Category for Adverse Event", AESCAT char(100)"Subcategory for Adverse Event",AEPRESP char(100)"PreSpecified Adverse Event",AEBODSYS char(100)"Body System or Organ Class",AELOC char(100)"Location of Event", AESEV char(100)"Severity/Intensity",AESER char(100)"Serious Event",AEACN char(100)"Action Taken with Study Treatment",AEACNOTH char(100)"Other Action Taken", AEREL char(100)"Causality",AERELNST char(100)"Relationship to Non-Study Treatment",AEPATT char(100)"Pattern of Adverse Event", AEOUT char(100)"Outcome of Adverse Event",AESCAN char(100)"Involves Cancer",AESCONG char(100)"Congenital Anomaly or Birth Defect",AESDISAB char(100)"Persist or Signif Disability/Incapacity", AESDTH char(100)"Results in Death",AESHOSP char(100)"Requires or Prolongs Hospitalization",AESLIFE char(100)"Is Life Threatening",AESOD char(100)"Occurred with Overdose",AESMIE char(100)"Other Medically Important Serious Event", AECONTRT char(100)"Concomitant or Additional Trtmnt Given",AETOXGR char(100)"Standard Toxicity Grade",AESTDTC char(100)"Start Date/Time of Adverse Event",AEENDTC char(100)"End Date/Time of Adverse Event",AESTDY num "Study Day of Start of Adverse Event ", AEENDY num "Study Day of End of Adverse Event",AEDUR char(100)"Duration of Adverse Event",AEENRF char(100)"End Relative to Reference Period",AEENRTPT char(100)"End Relative to Reference Time Point", AEENTPT char(100)"End Reference Time Point"); describe table AE_1; quit; /*SAMPLE CODE: CONVERTING NUMERIC DATA/TIME TO ISO8601 STANDARD FORMAT*/ /*o The PUT statements can convert a numeric Data/Time to ISO8601 standard format.*/ MYDATEC = put(MYDATE, is8601da.); if MYTIME ne . then MYTIMEC = put(MYTIME, is8601tm.); if MYTIMEC = '' then CFDTC = MYDATEC; else CFDTC = trim(MYDATEC) || "T" || trim(MYTIMEC); /*stsec=input(scan(sttimec, 3, ':'), best8.);*/ /*SUGGESTED SOLUTION When seconds are not collected, we recommend using MINUTES as the interval. In the situation demonstrated here, the statement should be fixed as follows:*/ A6dtm=intnx('minutes', adtm, 360); /*When seconds are collected, we recommend using SECONDS as the interval.*/ A6dtm=intnx('seconds', adtm, 360*60); proc sort data=rawdata.admin2 out=admin2;

by studyno; run; proc sort data=rawdata.randfile out=randfile; by studyno; run; proc sort data=rawdata.register out=register(rename=(sex=sexn race=racen)); by studyno; run; data readata; merge admin2(in=a) randfile(in=ra) register(in=re); by studyno; run; data target.dm; set readata; length STUDYID SUBJID USUBJID SITEID INVID INVNAM RACE ETHNIC ARM $40 DOMAIN $8 RFSTDTC RFENDTC BRTHDTC DMDTC $64 AGEU $10 ARMCD $20 SEX $1 COUNTRY $3 AGE DMDY 8; keep STUDYID DOMAIN USUBJID SUBJID RFSTDTC RFENDTC SITEID INVID INVNAM BRTHDTC AGE AGEU SEX RACE ETHNIC ARMCD ARM COUNTRY DMDTC DMDY; STUDYID='NIC001'; DOMAIN='DM'; USUBJID=LEFT(PUT(STUDYNO,Z6.)); SUBJID=SUBSTR(COMPRESS(PUT(STUDYNO,Z6.)),4,3); /*rfstdtc*/ if nmiss(TXBEGDAT,TXBEGTIM)=0 then RFSTDTC=PUT(DHMS(TXBEGDAT ,0,0,TXBEGTIM ),IS8601DT.); if nmiss(TXENDDAT,TXENDTIM)=0 then RFENDTC=PUT(DHMS(TXENDDAT ,0,0,TXENDTIM ),IS8601DT.); SITEID=SUBSTR(RPTINV,1,3); INVID=' '; INVNAM=PUT(RPTINV,$INV.); /*not understand*/ if nmiss(DOB)=0 then BRTHDTC=PUT(DOB,IS8601DA.); if nmiss(DOB,ADMDAT)=0 then AGE=(FLOOR((INTCK('month',DOB ,ADMDAT ) - (DAY(ADMDAT ) < DAY(DOB ))) / 12)); AGEU='YEARS'; SEX=SUBSTR(PUT(SEXN,SEX.),1,1); RACE=PUT(RACEN,RACE.); ETHNIC=' '; if TRT='A' then ARMCD='NIC15'; else if TRT='B' THEN ARMCD='PLA'; ELSE ARMCD=''; ARM=PUT(TRT,$TREAT.);

COUNTRY='USA'; DMDTC=PUT(ADMDAT,IS8601DA.); /*DMDY*/ if nmiss(txbegdat,admdat)=0 then do; if txbegdat >= admdat then dmdy = txbegdat - admdat + 1; else dmdy = txbegdat - admdat; end; /*label STUDYID='Study Identifier'*/ /*DOMAIN='Domain Abbreviation'*/ /*USUBJID='Unique Subject Identifier'*/ /*SUBJID='Subject Identifier for the Study'*/ /*RFSTDTC='Subject Reference Start Date/Time'*/ /*RFENDTC='Subject Reference End Date/Time'*/ /*SITEID='Study Site Identifier'*/ /*INVID='Investigator Identifier'*/ /*INVNAM='Investigator Name'*/ /*BRTHDTC='Date/Time of Birth'*/ /*AGE= 'Age in AGEU at RFSTDTC'*/ /*AGEU='Age Units'*/ /*SEX='Sex'*/ /*RACE='Race'*/ /*ETHNIC='Ethnicity'*/ /*ARMCD='Planned Arm Code'*/ /*ARM='Description of Planned Arm'*/ /*COUNTRY='Country'*/ /*DMDTC='Date/Time of Collection'*/ /*DMDY='Study Day of Collection' ;*/ /*run;*/

**** MERGE SOURCE DATA THEN DEFINE AND DERIVE DM SDTM VARIABLES; data target.dm; merge sasuser.admin2 sasuser.randfile sasuser.register(rename=(sex=_sex race=_race)); by studyno; **** CHECK FOR UNIQUENESS OF PRIMARY KEY; if not (first.studyno and last.studyno) then put "WARN" "NING: duplicate patient identifiers " studyno=; **** DEFINE DM VARIABLES; /*keep STUDYID DOMAIN USUBJID SUBJID RFSTDTC RFENDTC SITEID INVID INVNAM BRTHDTC AGE AGEU SEX RACE ETHNIC ARMCD ARM COUNTRY DMDTC DMDY;*/ /*attrib STUDYID length = $40 label = 'Study Identifier';*/ /*attrib DOMAIN length = $8 label = 'Domain Abbreviation';*/ /*attrib USUBJID length = $40 label = 'Unique Subject Identifier'; */ /*attrib SUBJID length = $40 label = 'Subject Identifier for the Study';*/ /*attrib RFSTDTC length = $64 label = 'Subject Reference Start Date/Time';*/ /*attrib RFENDTC length = $64 label = 'Subject Reference End Date/Time';*/

/*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib /*attrib

SITEID length = $40 label = 'Study Site Identifier';*/ INVID length = $40 label = 'Investigator Identifier'; */ INVNAM length = $40 label = 'Investigator Name';*/ BRTHDTC length = $64 label = 'Date/Time of Birth';*/ AGE length = 8 label = 'Age in AGEU at RFSTDTC';*/ AGEU length = $10 label = 'Age Units';*/ SEX length = $2 label = 'Sex';*/ RACE length = $40 label = 'Race';*/ ETHNIC length = $40 label = 'Ethnicity'; */ ARMCD length = $20 label = 'Planned Arm Code';*/ ARM length = $40 label = 'Description of Planned Arm'; */ COUNTRY length = $3 label = 'Country';*/ DMDTC length = $64 label = 'Date/Time of Collection';*/ DMDY length = 8 label = 'Study Day of Collection';*/

**** DERIVE SDTM DM VARIABLES; studyid = "NIC001"; domain = "DM"; usubjid = left(put(studyno,z6.)); subjid = substr(compress(put(studyno,z6.)),4,3); if txbegdat ne . and txbegtim ne . then rfstdtc = put(dhms(txbegdat, 0, 0, txbegtim), is8601dt.); if txenddat ne . and txendtim ne . then rfendtc = put(dhms(txenddat, 0, 0, txendtim), is8601dt.); siteid = substr(rptinv,1,3); invid = ''; /*format*/ invnam = put(rptinv,$inv.); brthdtc = put(dob,is8601da.); age = floor((intck('month',dob ,admdat ) - (day(admdat) < day(dob ))) / 12); ageu = 'YEARS'; /*do like this*/ sex = substr(put(_sex,sex.),1,1); race = put(_race,race.); ethnic = ''; if trt = 'A' then armcd = 'NIC15'; else if trt = 'B' then armcd = 'PLA'; arm = put(trt,$treat.); country = 'USA'; dmdtc = put(admdat,is8601da.); if txbegdat >= admdat then dmdy = txbegdat - admdat + 1; else dmdy = txbegdat - admdat; run;

/*Formats*/ /*to search formats*/ options fmtsearch =(library apple); proc format; /*library=apple;*/ value sev 1 = 'MILD' 2 = 'MODERATE' 3 = 'SEVERE' 4 = 'LIFE THREATENING OR DISABLING' 5 = 'DEATH RELATED'; value $yn upcase'yes'= 'Y' 'No'='N' 'UNK'='U'; value $action_taken UPCASE'None'='DOSE NOT CHANGED' 'DRUG PERMANENTLY DISCONTINUED'='DRUG WITHDRAWN' 'DOSE INCREASED'='DOSE INCREASED' 'DOSE HELD'='DOSE INTERRUPTED' 'DOSE DECREASED'='DOSE REDUCED' 'INFUSION INTERRUPTED'='DRUG INTURRUPTED' 'INFUSION RATE DECREASED'='NOT APPLICABLE'; VALUE $INRANGE UPCASE'N'='NORMAL' 'L'='LOW' 'H'='HIGH'; run; DATA PAR; INPUT SUM y $; DATALINES; 1 yes 2 YES 3 Yes run; data par1; set par; sev=put(sum,sev.); yy=upcase(put(y,$yn.)); run;

proc sql; create table SUPPDM_1 (STUDYID char(100)"Study Identifier",RDOMAIN char(100)"Related Domain Abbreviation",USUBJID char(100)"Unique Subject Identifier", IDVAR char(100)"Identifying Variable",IDVARVAL char(100)"Identifying Variable Value",QNAM char(100)"Qualifier Variable Name", QLABEL char(100)"Qualifier Variable Label",QVAL char(100)"Data Value",QORIG char(100)"Origin", QEVAL char(100)"Evaluator"; describe table SUPPDM_1; quit; /*To look details of formats in library*/ proc format library=test fmtlib;

run;

You might also like