/*-------------------------------------------------------------------\ | Product/Project: Get AE listing | | for RID-AF study | | Program: aeods.sas | | Author: Duo Zhou | | Date Written: 1/30/2002 | | Updated: | | Notes: This program was originally written by Amy Xia, it utilized | | DDE to transfer SAS data to Word document, however, it isn't| | efficient at all, so I did most of the modification using | | ODS and PROC TEMPLATE; now, the program is very fast. | | Keyword: ODS, PROC TEMPLATE; | \-------------------------------------------------------------------*/ *options symbolgen mprint yearcutoff=1920 ps=110 ls=79; options source noxwait noxsync yearcutoff=1920; %include "J:\CLINICAL\TACHY\BIOSTAT\Duo\Projects\ACED-RID\RID-AF\request\aetemplate.sas"; libname extract 'J:\clinical\tachy\amyx\ridaf\views'; libname ssd 'J:\clinical\tachy\amyx\ridaf\datasets'; libname library 'J:\clinical\tachy\amyx\ridaf\datasets'; * get the implanted lead model; data implant; set ssd.impldvn; by pt; length vlead vleado alead vlocat alocat olead1 olead2 $200.; array old1 (6) $ vmod1 vloc1 amod1 aloc1 mnum1 mnum7; array old2 (6) $ vmod2 vloc2 amod2 aloc2 mnum2 mnum8; array old3 (6) $ vmod3 vloc3 amod3 aloc3 mnum3 mnum9; array old4 (6) $ vmod4 vloc4 amod4 aloc4 mnum4 mnum10; array old5 (6) $ vmod5 vloc5 amod5 aloc5 mnum5 mnum11; array old6 (6) $ vmod6 vloc6 amod6 aloc6 mnum6 mnum12; array new1 (6) $ vmodd1 vlocc1 amodd1 alocc1 mnumm1 mnumm7; array new2 (6) $ vmodd2 vlocc2 amodd2 alocc2 mnumm2 mnumm8; array new3 (6) $ vmodd3 vlocc3 amodd3 alocc3 mnumm3 mnumm9; array new4 (6) $ vmodd4 vlocc4 amodd4 alocc4 mnumm4 mnumm10; array new5 (6) $ vmodd5 vlocc5 amodd5 alocc5 mnumm5 mnumm11; array new6 (6) $ vmodd6 vlocc6 amodd6 alocc6 mnumm6 mnumm12; do i=1 to dim(old1); if sysimpn1 = 1 then new1{i} = old1{i}; else new1{i} = ''; if sysimpn2 = 1 then new2{i} = old2{i}; else new2{i} = ''; if sysimpn3 = 1 then new3{i} = old3{i}; else new3{i} = ''; if sysimpn4 = 1 then new4{i} = old4{i}; else new4{i} = ''; if sysimpn5 = 1 then new5{i} = old5{i}; else new5{i} = ''; if sysimpn6 = 1 then new6{i} = old6{i}; else new6{i} = ''; end; vlead=left(trimn(vmodd1))||left(trimn(vmodd2))||left(trimn(vmodd3)) ||left(trimn(vmodd4))||left(trimn(vmodd5))||left(trimn(vmodd6)); vleado=left(trimn(vmod1))||left(trimn(vmod2))||left(trimn(vmod3)) ||left(trimn(vmod4))||left(trimn(vmod5))||left(trimn(vmod6)); alead=left(trimn(amodd1))||left(trimn(amodd2))||left(trimn(amodd3)) ||left(trimn(amodd4))||left(trimn(amodd5))||left(trimn(amodd6)); vlocat=left(trimn(vlocc1))||left(trimn(vlocc2))||left(trimn(vlocc3)) ||left(trimn(vlocc4))||left(trimn(vlocc5))||left(trimn(vlocc6)); alocat=left(trimn(alocc1))||left(trimn(alocc2))||left(trimn(alocc3)) ||left(trimn(alocc4))||left(trimn(alocc5))||left(trimn(alocc6)); olead1=left(trimn(mnumm1))||left(trimn(mnumm2))||left(trimn(mnumm3)) ||left(trimn(mnumm4))||left(trimn(mnumm5))||left(trimn(mnumm6)); olead2=left(trimn(mnumm7))||left(trimn(mnumm8))||left(trimn(mnumm9)) ||left(trimn(mnumm10))||left(trimn(mnumm11))||left(trimn(mnumm12)); run; proc sort data=ssd.ae out=ae; by pt dcmdate; run; data comb; merge implant(in=x keep=pt dcmdate devsn vlead alead olead1 olead2 leadsr1-leadsr4 rename=(dcmdate=idt)) ae(in=y rename=(dcmdate=aedt logints=logdt)); by pt; length actiondscp aedscp keyterm $1000. implantsys _tmp1 icdm aleadm vleadm oleadm1 oleadm2 outcome $200.; format idate aedate resdate logindate mmddyy10.; if x and y; aedate = INPUT(SUBSTR(aedt,1,8), YYMMDD8.); idate = input(substr(idt,1,8),yymmdd8.); resdate = input(substr(resoldt,1,8),yymmdd8.); logindate = datepart(logdt); drop idt aedt; if aeout = 'RESOLVED' then outcome = left(trimn(aeout))||' '||left(trimn(put(resdate,mmddyy10.))); else outcome = left(trimn(aeout)); /* define comp vs obs */ array aeact(5) aeact1-aeact5; array compind(5) compind1-compind5; do i=1 to dim(aeact); if index(aeact{i}, 'INVASIVE INTERVENTION') then compind{i} = 1; else compind{i} = 0; end; sumcomp = sum(of compind1-compind5); if sumcomp > 0 then compobs = 'Complication'; else compobs = 'Observation'; /* define action taken */ actiondscp = left(trimn(aeact1))||' '||left(trimn(aeact2))||' '||left(trimn(aeact3)) ||' '||left(trimn(aeact4))||' '||left(trimn(aeact5)) ||' '||left(trimn(othsp2))||' '||left(trimn(othsp3)) ||' '||left(trimn(othsp4)); aedscp = left(trimn(aedesc1))||' '||left(trimn(aedesc2))||' '||left(trimn(aedesc3)) ||' '||left(trimn(aedesc4))||' '||left(trimn(aedesc5))||' '||left(trimn(aedesc6)); aedesc1 = compress(aedesc1,'"');aedesc1 = compress(aedesc1,"'"); aedesc2 = compress(aedesc2,'"');aedesc2 = compress(aedesc2,"'"); aedesc3 = compress(aedesc3,'"');aedesc3 = compress(aedesc3,"'"); aedesc4 = compress(aedesc4,'"');aedesc4 = compress(aedesc4,"'"); aedesc5 = compress(aedesc5,'"');aedesc5 = compress(aedesc5,"'"); aedesc6 = compress(aedesc6,'"');aedesc6 = compress(aedesc6,"'"); keyterm = left(trimn(aecode1))||' '||left(trimn(aecode2))||' '||left(trimn(aecode3)) ||' '||left(trimn(aecode4))||' '||left(trimn(aecode5)) ||' '||left(trimn(aecode6))||' '||left(trimn(othsp1)); if substr(devsn,1,3) = 'PKE' then icdm = '7276/'||left(trimn(devsn)); else if substr(devsn,1,3) = 'PID' then icdm = '7250/'||left(trimn(devsn)); else icdm = ''; if not missing(vlead) and not missing(leadsr1) then vleadm=trimn(left(vlead))||'/'||trimn(left(leadsr1)); else if not missing(vlead) then vleadm=trimn(left(vlead)); else if not missing(leadsr1) then vleadm = trimn(left(leadsr1)); else vleadm=''; if not missing(alead) and not missing(leadsr2) then aleadm=trimn(left(alead))||'/'||trimn(left(leadsr2)); else if not missing(alead) then aleadm=trimn(left(alead)); else if not missing(leadsr2) then aleadm = trimn(left(leadsr2)); else aleadm=''; if not missing(olead1) and not missing(leadsr3) then oleadm1=trimn(left(olead1))||'/'||trimn(left(leadsr3)); else if not missing(olead1) then oleadm1=trimn(left(olead1)); else if not missing(leadsr3) then oleadm1 = trimn(left(leadsr3)); else oleadm1=''; if not missing(olead2) and not missing(leadsr4) then oleadm2=trimn(left(olead2))||'/'||trimn(left(leadsr4)); else if not missing(olead2) then oleadm2=trimn(left(olead2)); else if not missing(leadsr4) then oleadm2 = trimn(left(leadsr4)); else oleadm2=''; implantsys=''; if not missing(icdm) then do; _tmp1=trimn(left(aleadm))||''||trimn(left(vleadm))||''||trimn(left(oleadm1))||''||trimn(left(oleadm2)); if not missing(_tmp1) then implantsys=trimn(left(implantsys))||trimn(left(icdm))||';'||' '||'0D'x; else implantsys=trimn(left(implantsys))||trimn(left(icdm)); end; if not missing(aleadm) then do; _tmp1=trimn(left(vleadm))||''||trimn(left(oleadm1))||''||trimn(left(oleadm2)); if not missing(_tmp1) then implantsys=trimn(left(implantsys))||trimn(left(aleadm))||';'||' '||'0D'x; else implantsys=trimn(left(implantsys))||trimn(left(aleadm)); end; if not missing(vleadm) then do; _tmp1=trimn(left(oleadm1))||''||trimn(left(oleadm2)); if not missing(_tmp1) then implantsys=trimn(left(implantsys))||trimn(left(vleadm))||';'||' '||'0D'x; else implantsys=trimn(left(implantsys))||trimn(left(vleadm)); end; if not missing(oleadm1) then do; _tmp1=trimn(left(oleadm2)); if not missing(_tmp1) then implantsys=trimn(left(implantsys))||trimn(left(oleadm1))||';'||' '||'0D'x; else implantsys=trimn(left(implantsys))||trimn(left(oleadm1)); end; if not missing(oleadm2) then implantsys=trimn(left(implantsys))||trimn(left(oleadm2)); label pt = 'Patient ID' implantsys="Implanted System" idate = 'Implant Date' aedate = 'Event Date' compobs = 'AE Type' keyterm = 'Key Term' aedscp = 'AE Description' actiondscp = 'Action Taken' outcome = 'Outcome of Event' impsysn = 'Relationship to System (Investigator)' improcn = 'Relationship to Procedure (Investigator)' logindate="Event Logged Date"; run; /*%print(comb, var=pt logindate, where=(logindate is not missing));*/ ods listing close; ods html file="J:\CLINICAL\TACHY\BIOSTAT\Duo\Projects\ACED-RID\RID-AF\request\aeprint.doc"; ods path mytmpl.tmplmst(read); data _null_; format idate aedate resdate logindate mmddyy10.; set comb; file print ods = ( template='ae.tmpl' columns=( pt=pt(generic=on) implantsys=implantsys(generic=on) idate=idate(generic=on) aedate=aedate(generic=on) compobs=compobs(generic=on) keyterm=keyterm(generic=on) aedscp=aedscp(generic=on) actiondscp=actiondscp(generic=on) outcome=outcome(generic=on) impsysn=impsysn(generic=on) improcn=improcn(generic=on) logindate=logindate(generic=on) ) ); put _ods_; run; ods html close; ods listing; /* proc print data=comb(obs=10); var pt implantsys; run;*/