/*macro created for the sorting process*/
%macro msort (indata=, outdata=, var=);

proc sort data=&indata out=&outdata;
by &var;
run;

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

%mend msort;

/*macro created for the transposing process*/
%macro mtrans (indata=, outdata=, by=, id=, var=);

proc transpose data = &indata out = &outdata;
by &by;
id &id;
var &var;
run;

%mend mtrans;

proc format;
value $conv
“01”=”JAN”
“02”=”FEB”
“03”=”MAR”
“04”=”APR”
“05”=”MAY”
“06”=”JUN”
“07”=”JUL”
“08”=”AUG”
“09”=”SEP”
“10”=”OCT”
“11”=”NOV”
“12”=”DEC”;
run;

%macro repeat (param=xxx,outid=);
** XXX IS ANY PARAMETER NEEDED TO GENERATE THE REPEAT OUTPUT **;
**———————————————————————-**;
** WRITE PROGRAM CODE HERE **;
** DO NOT MODIFY OR COMMENT OUT EXISTING CODE **;
**———————————————————————-**;
%msort(indata=adcm /*(where = (upcase(cmcat)=”GENERAL” ))*/, outdata=adcm1, var=studyid usubjid cmseq);
%msort(indata=suppcm (where = (upcase(qnam) in (“FREQSP” “CMINDENO” “DOSUSP” “ROUTESP”))), outdata=suppcm1, var=studyid usubjid idvar idvarval);
%mtrans(indata=suppcm1, outdata=suppcm2 (drop=_:), by=studyid usubjid idvar idvarval, id=qnam, var=qval);
%msort(indata=cm /*(where = (upcase(cmcat)=”GENERAL”))*/, outdata=cm_, var=studyid usubjid cmseq);

data suppcm3 (drop=idvar idvarval);
set suppcm2;
cmseq=input(idvarval,best12.);
run;

%msort(indata=suppcm3, outdata=suppcm4, var=studyid usubjid cmseq);

data cm2;
merge adcm1(in=a) suppcm4(in=b);
by studyid usubjid cmseq;

if a;
run;

?
data cm3;
merge cm2(in=a drop = cmspid cmtrt cmdecod cmcat cmstdtc cmendtc cmenrf cmindc) cm_ (in=b);
by studyid usubjid cmseq;

if a and b;
run;

data cm4;
set cm3;
where upcase(cmfl) eq “Y”;
run;

data cm4;
length col11 $25. col4 $20. col5 $20.;
set cm3;
if treat = “” then treat = “None”;
col1=strip(substr(usubjid,13));
col2= propcase(strip(cmtrt));
if not missing(atc1txt) and not missing(cmdecod) then
col3= strip(Propcase(atc1txt))||”/~n”||strip(propcase(cmdecod));

if astdt = tr01edt and astdt ne . then
col4=compress(strip(put(astdt,date9.))||”/~n”||strip(put(astdy,best.))||”L”);
else if astdt>tr01edt and astdt ne . and tr01edt ne . then
do;
stdy=astdt-tr01edt;
col4=compress(strip(put(astdt,date9.)||”/~n”||put(stdy,best.)||”P”));
end;
else if astdy eq . and astdt ne . then
col4=compress(strip(put(astdt,date9.)));
else if astdt ne . and astdy ne . then
col4=compress(strip(put(astdt,date9.))||”/~n”||strip(put(astdy,best.)));

if aendt = tr01edt and tr01edt ne . then
col5=compress(strip(put(aendt,date9.))||”/~n”||strip(put(aendy,best.))||”L”);
else if aendt>tr01edt and aendt ne . and tr01edt ne . then
do;
endy=aendt-tr01edt;
col5=compress(strip(put(aendt,date9.))||”/~n”||strip(put(endy,best.))||”P”);
end;
else if aendt ne . and aendy ne . then
col5=compress(strip(put(aendt,date9.)||”/~n”||put(aendy,best.)));
else if aendt ne . and aendy eq . then
col5=compress(strip(put(aendt,date9.)));
else if upcase(cmenrf) eq “ONGOING” then
col5=”ONGOING”;

if cmdose ne . then
col6=strip(put(cmdose,best.));

if cmdosu ne ” ” and upcase(cmdosu) in (“OTHER”) then
do;
if dosusp ne ” ” then
col7=strip(upcase(cmdosu))||”: “||strip(DOSUSP);

if dosusp eq ” ” then
col7=strip(upcase(cmdosu));
end;

if cmdosu ne ” ” and upcase(cmdosu) not in (“OTHER”) then
col7=strip(cmdosu);

if cmroute ne ” ” and upcase(cmroute) in (“OTHER”) then
do;
if routesp ne ” ” then
col8=strip(upcase(cmroute))||”: “||propcase(strip(routesp));

if routesp eq ” ” then
col8=strip(upcase(cmroute));
end;

if cmroute ne ” ” and upcase(cmroute) not in (“OTHER”) then
col8=propcase(strip(cmroute));

if cmdosfrq ne ” ” and upcase(cmdosfrq) in (“OTHER”) then
do;
if freqsp ne ” ” then
col9=strip(upcase(cmdosfrq))||”: “||propcase(strip(freqsp));

if freqsp eq ” ” then
col9=strip(upcase(cmdosfrq));
end;

if cmdosfrq ne ” ” and upcase(cmdosfrq) not in (“OTHER”) then
col9=strip(cmdosfrq);
indc=Propcase(cmindc);

if indc ne ” ” then
col10=strip(indc);

if upcase(cmindc) in (“ADVERSE EVENT”) then
col11=compress(cmindeno);
run;

%msort(indata=cm4, outdata=cm5, var=studyid treatn treat usubjid cmtrt col1 astdt aendy);

data final (drop=seq cmspid);
retain pg;
retain studyid treatn treat usubjid cmtrt col1 col1 astdt aendy col2-col11;
set cm5;
by studyid treatn treat usubjid cmtrt col1 astdt aendy;

if first.treatn then
seq=1;
else seq+1;

if first.treatn and _n_=1 then
pg=1;
else if mod(seq,5)=1 then
pg+1;
run;

**——————————————————————————————————-**;
** FINAL DATASET IN THIS SECTION MUST BE NAMED ‘FINAL’. FINAL DATASET IS INPUT TO DATASTEP BELOW. **;
**——————————————————————————————————-**;
** QC OUTPUT DATASET **;
data qc.&outid (keep=treat col:);
** DROP ANY VARIABLES THAT ARE NOT NECESSARY FOR COMPARISON IN VALIDATION PROGRAM **;
set final;
run;

**———————————————————————-**;
** CREATE TLF **;
**———————————————————————-**;
%mrtfset(outid=&outid);
option nobyline;
title6 j=l “Treatment Group: #byval(treat)”;

** SAMPLE PROC REPORT. MODIFY ACCORDINGLY **;
proc report data=final missing nowindows center split=’|’ style(report)={outputwidth=9in}
style(header column)={font_face=’Times New Roman’ font_size=9PT};
column pg studyid treatn treat usubjid col1 cmtrt astdt col2-col11;
by studyid treatn treat;
define pg / order noprint;
define studyid / noprint;
define treatn / order noprint;
define treat / order noprint;
define usubjid / order noprint;
define col1/order order=internal “Patient|Number”
style(header)=just=left
style(column)=just=left cellwidth=.34in cellspacing=10pt flow;
define cmtrt/order noprint;
define col2/ “Concomitant|Medication”
style(header)=just=left
style(column)=just=left cellwidth=.80in cellspacing=10pt flow;
define col3/ order “ATC Class /|Preferred Name”
style(header)=just=left
style(column)=just=left cellwidth=.85in cellspacing=2pt flow;
define astdt/order noprint;
define col4/ “Start|Date/|Rel Day|1”
style(header)=just=left
style(column)=just=left cellwidth=.45in cellspacing=3pt flow;
define col5/ “Stop|Date/|Rel Day” flow
style(header)=just=left
style(column)=just=left cellwidth=.45in cellspacing=3pt flow;
define col6/ “Dose”
style(header)=just=left
style(column)=just=left cellwidth=.25in cellspacing=3pt flow;
define col7/ “Unit”
style(header)=just=left
style(column)=just=left cellwidth=.32in cellspacing=3pt flow;
define col8/ “Route”
style(header)=just=left
style(column)=just=left cellwidth=.30in cellspacing=3pt flow;
define col9/ “Frequency”
style(header)=just=left
style(column)=just=left cellwidth=.39in cellspacing=3pt flow;
define col10/”Indication Type”
style(header)=just=left
style(column)=just=left cellwidth=.68in cellspacing=3pt flow;
define col11/left “AE|Number”
style(header)=just=left
style(column)=just=left cellwidth=.30in cellspacing=3pt flow;

** SKIP A LINE AFTER CATEGORY 3 **;

/* compute before col1;*/
/* line ‘ ‘;*/
/* endcomp;*/

compute before col3;
line ‘ ‘;
endcomp;

** PAGE BREAK AFTER CATEGORY 2 **;
break after pg / page;
run;

**—– CLOSE RTF AND RESET TITLES/FOOTNOTES —–**;
ods rtf close;
ods listing;
options date number;
%mend repeat;

%repeat(param=xxx,outid=L16297);

* CHANGE XXX TO THE PARAMETER FROM MACRO CALL;
** LOG CHECK **;
%mendprog;

Post Author: admin

x

Hi!
I'm Eileen!

Would you like to get a custom essay? How about receiving a customized one?

Check it out