0% found this document useful (0 votes)
65 views15 pages

Hosp All

This SAS program reads in clinical trial data from various datasets and performs data cleaning and transformations to prepare the data for analysis. It merges datasets, sorts the data, creates new variables, subsets the data, and outputs new datasets. The overall goal is to categorize and count hospitalization events and durations using the patient-level clinical trial data.

Uploaded by

gowtham.rupa07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views15 pages

Hosp All

This SAS program reads in clinical trial data from various datasets and performs data cleaning and transformations to prepare the data for analysis. It merges datasets, sorts the data, creates new variables, subsets the data, and outputs new datasets. The overall goal is to categorize and count hospitalization events and durations using the patient-level clinical trial data.

Uploaded by

gowtham.rupa07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

*********************************************************************************;

* Program Name: T-hosp-all.sas *

options mprint nofmterr missing='' ls=&ls ps=&ps;


options minoperator mindelimiter=',' noquotelenmax;

*******************************************************************************;
*** Read in ADSL ADHOSP ADAE Dataset ***;
*******************************************************************************;

proc datasets lib=work nolist kill; run;

%xudata1(adsl adhosp adae , libref =adam, select= where saffl='Y');

PROC SQL;
select distinct dcutdt into: dcutdt
from adsl;
quit;

%put &dcutdt;

data hosp;
merge adsl(in=a) adhosp(in=b);
by usubjid;
if a and b;
run;

proc sort data=hosp; by usubjid hostdt hoendt; run;

data firsthosp;
set hosp;
by usubjid hostdt;
if first.usubjid;
run;

***dataset for 2nd section***;

proc sort data=hosp out=hosp1;by usubjid hostdt hoendt;run;

data hosp2;
set hosp1;
by usubjid hostdt;
if first.usubjid then seq=1;
else seq+1;
if last.usubjid;

length seqcat $200;***making category 1 or >1, for using later for counting***;
if seq=1 then seqcat='Patients with 1 hospitalization';
else if seq>1 then seqcat='Patients with >1 hospitalizations';
run;

***dataset for 3rd section***;

data durcat;
set firsthosp;
by usubjid hostdt hoendt;
length durcat $200;format hostdt1 hostdt2 hostdt3 hostdt4 hostdt5 date9.;
retain hostdt1 hostdt2 hostdt3 hostdt4 hostdt5;

hostdt1=trtsdt+30.4375-1;
hostdt2=(hostdt1+30.4375);
hostdt3=(hostdt2+30.4375);
hostdt4=(hostdt3+30.4375);
hostdt5=(hostdt4+30.4375);
hostdt6=(hostdt5+30.4375);

if hostdt<trtsdt then do;durcat=' Prior to Day 1';durcatn=1;end;


else if (hostdt>=trtsdt and hostdt<=hostdt1) then do;durcat=' During month
1';durcatn=2;end;
else if (hostdt>hostdt1 and hostdt<=hostdt2) then do;durcat=' During month
2';durcatn=3;end;
else if (hostdt>hostdt2 and hostdt<=hostdt3) then do;durcat=' During month
3';durcatn=4;end;
else if (hostdt>hostdt3 and hostdt<=hostdt4) then do;durcat=' During month
4';durcatn=5;end;
else if (hostdt>hostdt4 and hostdt<=hostdt5) then do;durcat=' During month
5';durcatn=6;end;
else if (hostdt>hostdt5 and hostdt<=hostdt6) then do;durcat=' During month
6';durcatn=7;end;
else if hostdt>hostdt6 then do;durcat=' After month 6';durcatn=8;end;
run;

data alivestay_;
merge hosp1(in=a) adsl(in=b);
if a and b;
by usubjid;
run;
proc sort nodupkey;by usubjid;run;

data alivestay;
set alivestay_;
dthdt_= dthdt; trtsdt_= trtsdt;
if DTHDT_ ne . and TRTSDT_ <= DTHDT_ <= TRTSDT_+89 then alive_stay= DTHDT_ -
TRTSDT_ +1;
Else alive_stay= 90;
run;

******Macro for overlapping days count****;


proc sort data =hosp1;by usubjid hostdt hoendt;run;

data hosp11;
set hosp1;
if hostdt<trtsdt then hostdt=trtsdt;
if hostdt >=trtsdt;
if hoendt=. then hoendt='18mar2021'd;
run;

data Totdays;
set hosp11;
run;

data d190_;
set hosp1/*(rename=(trta=trt01a trtan=trt01an))*/;
if hoendt ne . then do;
if hostdy>90 or hoendt < trtsdt then delete;****hosp starts after day90, deleted**;
end;
if hostdt<trtsdt then hostdt=trtsdt;
***resetting hosp start date if before Day 1, hosp count only from trtsdt****;
if hoendt>(trtsdt+89) then hoendt=trtsdt+89;****keeping enddate as upto D90 days**;
/*keep usubjid hostdt hoendt trt01a trt01an;*/
run;

data d190;
set d190_;
if hostdt<trtsdt then hostdt=trtsdt;
if hostdt >=trtsdt;
if hoendt=. then hoendt='18mar2021'd;
if hoendt>(trtsdt+89) then hoendt=trtsdt+89;
run;

data chk_;
set hosp1/*(rename=(trta=trt01a trtan=trt01an))*/;
where hostdy >=1 ;
keep usubjid hostdt hoendt trt01a trt01an trtsdt;
run;

data chk;
set chk_;
if hostdt<trtsdt then hostdt=trtsdt;
if hostdt >=trtsdt;
if hoendt=. then hoendt='18mar2021'd;
if hoendt>(trtsdt+89) then hoendt=trtsdt+89;
run;

data excludeaza_;
set hosp1/*(rename=(trta=trt01a trtan=trt01an))*/;
where ^(INDEX(HORESP,'AZA')>0 OR INDEX(HORESP,'Aza')>0);
/* keep usubjid hostdt hoendt trt01a trt01an horesp trtsdt;*/
run;

data excludeaza;
set excludeaza_;
if hostdt<trtsdt then hostdt=trtsdt;
if hostdt >=trtsdt;
if hoendt=. then hoendt='18mar2021'd;
if hoendt>(trtsdt+89) then hoendt=trtsdt+89;
run;

%macro hospital_eoh(dataset_in=,dataset_out=);
/* Step 1 - Number the sorted data for EoH */
data data_1;
set &dataset_in;
by usubjid hostdt hoendt;
retain n;
if first.usubjid then n=0;
n=n+1;
run;
/* Step 2 - Transpose the variables in hostdt and hoendt for EoH */
%macro eoh(inA=,inB=,outA=,from=,to=);
proc transpose data=&inA out=&outA (drop=_name_) prefix=&to;
by usubjid;
var &from;
run;
%mend;
%eoh(inA=data_1,outA=admit,from=hostdt,to=hostdt)
%eoh(inA=data_1,outA=dschg,from=hoendt,to=hoendt)
/* Step 3 - Combine the transposed admission & discharged date & main files */
%macro join(inA=, inB=, outA=, b=, xvar=);
data &outA;
merge &inA (in=x) &inB (in=y drop=&xvar);
by &b;
if x and y; run;
%mend;
%join(inA=admit, inB=dschg, outA=Admit_dschg, b=usubjid)
%join(inA=data_1, inB=Admit_dschg, outA=hospital_adm_dschg, b=usubjid)
proc sql;
select left(trim(put(MAX(count),5.))) into: Idy from
(select count(*) as count
from hospital_adm_dschg
group by usubjid);
QUIT;
%PUT &Idy;
proc sort data=hospital_adm_dschg;
by usubjid hostdt hoendt;
run;
/* Step 4 - Compute and assign EoH & Hospitalization Types */
data data_2 (drop= i diff done eoh2 seq2 hostdt1-hostdt&Idy hoendt1-
hoendt&Idy);
set hospital_adm_dschg;
by usubjid hostdt hoendt;
where n LE &Idy;

los = hoendt - hostdt + 1;


array adm (*) hostdt1-hostdt&Idy;
array dcg (*) hoendt1-hoendt&Idy;
retain eoh2 seq2; done=0;
if first.usubjid then do;
eoh1=0; eoh2=eoh1; seq=0; seq2=seq; nest=0; trans=0;
end;
if n = 1 then do;
eoh1=1; eoh2=eoh1; seq=1; seq2=seq; nest=0; trans=0;
if adm(2) ^= . AND adm(1) >= adm(2) and dcg(1) < dcg(2) then do;
eoh1=eoh2; seq=seq2; eoh2=eoh1; seq2=seq; nest=1; trans=0;
end;
end;
else if n = 2 then
do;
if 0 <= abs(adm(2)-dcg(1)) <= 1 and (dcg(2) > dcg(1) or
(dcg(2) = dcg(1))) then do;
eoh1=eoh2; seq=seq2+1; eoh2=eoh1; seq2=seq; nest=0;
trans=1;
end;
else if adm(2) >= adm(1) and (dcg(2) < dcg(1) or
(dcg(2) = dcg(1))) then do;
eoh1=eoh2; seq=seq2; eoh1=eoh2; seq=seq2; nest=1; trans=0;
end;
else if adm(3) ^= . AND adm(2) >= adm(3) and dcg(2) < dcg(3) then do;
eoh1=eoh2; seq=seq2; eoh2=eoh1; seq2=seq; nest=1; trans=0;
end;
else do;
eoh1=eoh2+1; seq=seq2; eoh2=eoh1; seq2=seq; nest=0; trans=0;
end;
end;
else if n > 2 then do;
do i=1 to n-1;
diff=abs(adm(n)-dcg(i));
if 0 <= abs(adm(n)-dcg(i)) <= 1 and
((dcg(n) > dcg(i) or dcg(n) = dcg(i))) then do;
eoh1=eoh2; seq=seq2+1; eoh2=eoh1; seq2=seq; nest=0;
trans=1; done=1;
leave;
end;
end;
do i=1 to n-1;
if not(done) and adm(n) >= adm(i) and (dcg(n) < dcg(i) or
(dcg(n)=dcg(i))) then do;
eoh1=eoh2; seq=seq2; eoh1=eoh2; seq=seq2; nest=1; trans=0;
done=1;
leave;
end;
end;
do i=1 to n-1;
if not(done) and abs(adm(n) - dcg(i)) > 1 then do;
done=1; seq=1; seq2=seq; eoh1=eoh2+1; eoh2=eoh1; nest=0;
trans=0;
leave;
end;
end;
if (n + 1) LE &Idy AND adm(n+1) ^= . and adm(n) >= adm(n+1) and dcg(n) <
dcg(n+1) then do;
eoh1=eoh2; seq=seq2; eoh2=eoh1; seq2=seq; nest=1; trans=0; done=1;
END;
end;

run;
proc sort data=data_2;
by usubjid eoh1 hostdt hoendt;
run;
/* Step 5 - Compute other variables (i.e. LOS) & prepare the final output */
DATA data_3; retain usubjid hostdt hoendt n eoh1 count nest trans los
/*EOH_LOS*/; SET data_2;
by usubjid eoh1 hostdt hoendt;
RETAIN count; count + 1;
IF FIRST.eoh1 THEN count = 1;
rename eoh1 = eoh;
rename n = total_hosp;
rename los = hosp_los;
drop seq;
run;
data data_nonest;
set data_3;
IF nest ^= 1;
run;
DATA data_4;
SET data_nonest;
BY usubjid EOH;
IF FIRST.EOH OR LAST.EOH;
hoendt_first = lag(hoendt);
hostdt_first = lag(hostdt);
usubjid_first = lag(usubjid);
EOH_first = lag(EOH);
IF usubjid = usubjid_first AND EOH = EOH_first THEN hostdt = hostdt_first;
IF LAST.eoh;
eoh_los = hoendt - hostdt + 1;
format hostdt hoendt date9.;
KEEP usubjid EOH eoh_los count;
RUN;
PROC SQL;
CREATE TABLE &dataset_out AS
SELECT a.*, b.eoh_los
FROM data_3 a LEFT JOIN data_4 b
ON a.usubjid = b.usubjid AND a.eoh = b.eoh
ORDER BY usubjid, EOH, hostdt, hoendt;
QUIT;
%mend hospital_eoh;

%hospital_eoh(dataset_in=Totdays,dataset_out=Totdays1)
%hospital_eoh(dataset_in=d190,dataset_out=d190out)
%hospital_eoh(dataset_in=chk,dataset_out=chk1)
%hospital_eoh(dataset_in=excludeaza,dataset_out=excludeazaout)

data exclude_beforeday1;
set chk1;
if count=1 and eoh_los>=1;
run;

data excludeazaout1;
set excludeazaout;
if count=1 and eoh_los>=1;
run;

data d190out1;
set d190out;
if count=1 and eoh_los>=1;
run;

data Totdayshosp;
set Totdays1;
if count=1 and eoh_los>=1;
run;

proc sql;
create table d190cnt as
select trt01an, trt01a, 5 as section, 20.5 as sord,
' day1-90' as text length=200,sum(eoh_los) as numer
from d190out1
group by trt01an, trt01a, section, sord, text;
quit;

proc sql;
create table alivecnt as
select trt01an, trt01a, 5 as section, 20.5 as sord,
'Total days alive during day 1 - day 90' as text length=200,sum(alive_stay) as
denom
from alivestay
where alive_stay ne . /*and durcatn in(2,3,4)*/
group by trt01an, trt01a, section, sord, text;
quit;
data aliveprcnt;
merge alivecnt(in=a) d190cnt(in=b);
format per 5.1;
by trt01a trt01an;
if a and b;
per= (numer/denom)*100;
run;

data hosp3;
length daysdur $40.;
set hosp11;
by usubjid hostdt hoendt;

hoendt_original=hoendt;/*keeping original dates before chaging***/


hostdt_original=hostdt;

****for section 6 Number of patients with >=1 hospitalization duration of


categories***;
hosp_stay_cat=hoendt_original - hostdt_original + 1;**for category purpose, using
original hoendt value***;

if hosp_stay_cat>=1 and hosp_stay_cat<=6 then do;daysdur='1 - 6


days';daysdurn=1;end;
if hosp_stay_cat>=7 and hosp_stay_cat<=13 then do;daysdur='7 - 13
days';daysdurn=2;end;
if hosp_stay_cat>=14 and hosp_stay_cat<=20 then do;daysdur='14 - 20
days';daysdurn=3;end;
if .<hosp_stay_cat>=21 then do;daysdur='~{unicode 2265} 21 days';daysdurn=4;end;

****for section 8 Time to Start of First Hospitalization (days)***;

if first.usubjid then tth=1;***only for First Time to hospitalization**;

/*keep usubjid hostdt hoendt trtsdt hostdy hoendy;*/


run;

data hosp33;
set hosp3;
if hoendt<hostdt then delete;
run;

/* 8 section*/

data firsthospdays;
set hosp3;
where tth=1;
firsthospdays=(hostdt-trtsdt)+1;
run;

proc sql noprint;


**scetion 1**;
create table counts as
select trt01an, trt01a, 1 as section, 10 as sord, 'Total number of hospitalized
patients' as text length=200,count(distinct usubjid) as smaln
from firsthosp
where hostdt ne .
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 1 as section, 11 as sord, ' First hospitalization began
before Day 1' as text length=200,count(distinct usubjid) as smaln
from firsthosp
where hostdt<trtsdt
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 1 as section, 12 as sord, ' First hospitalization began
on Day 1' as text length=200,count(distinct usubjid) as smaln
from firsthosp
where hostdt=trtsdt
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 1 as section, 13 as sord, ' First hospitalization began
after Day 1' as text length=200,count(distinct usubjid) as smaln
from firsthosp
where hostdt>trtsdt
group by trt01an, trt01a, section, sord, text

/*section 2*/
union
select trt01an, trt01a, 2 as section, 14 as sord, seqcat as text
length=200,count(distinct usubjid) as smaln
from hosp2
where seqcat>''
group by trt01an, trt01a, section, sord, text

/*section 3*/
union
select trt01an, trt01a, 3 as section, 15 as sord, durcat as text
length=200,count(distinct usubjid) as smaln
from durcat
where durcat>''
group by trt01an, trt01a, section, sord, text

/*section 4*/
union
select trt01an, trt01a, 4 as section, 16 as sord,
'Total days of hospitalization [1][2]' as text length=200,sum(eoh_los) as smaln
from totdayshosp
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 4 as section, 17 as sord,
' During day 1 - day 90' as text length=200,sum(eoh_los) as smaln
from d190out1
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 4 as section, 18 as sord,
' Subgroup excluding any stay began before day 1' as text
length=200,sum(eoh_los) as smaln
from exclude_beforeday1
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 4 as section, 19 as sord,
' Subgroup excluding Azacitidine dosing' as text length=200,sum(eoh_los) as
smaln
from excludeazaout1
group by trt01an, trt01a, section, sord, text

/*section 5*/
union
select trt01an, trt01a, 5 as section, 20 as sord, 'Total days alive during day 1 -
day 90' as text length=200,sum(alive_stay) as smaln
from alivestay
where alive_stay ne . /*and durcatn in(2,3,4)*/
group by trt01an, trt01a, section, sord, text

union
select trt01an, trt01a, 5 as section, 20.5 as sord, 'Hospital days per days alive
during day 1 - day 90 (%) [1][2][3]'
as text length=200,per as smaln
from aliveprcnt
group by trt01an, trt01a, section, sord, text

/*section 6*/
union
select trt01an, trt01a, 6 as section, 21 as sord,' '||strip(daysdur) as text
length=200,count(distinct usubjid) as smaln
from hosp3
where daysdur>''
group by trt01an, trt01a, section, sord, text

/*Section 7, unique n counts*/


union
select trt01an, trt01a, 7 as section, 22 as sord,'n' as text length=200,
count(distinct usubjid) as smaln
from hosp33
where hosp_stay_cat ne .
group by trt01an, trt01a, section, sord, text

/*Section 8, unique n counts*/


union
select trt01an, trt01a, 8 as section, 24 as sord,'n' as text length=200,
count(distinct usubjid) as smaln
from hosp3
where tth ne .
group by trt01an, trt01a, section, sord, text;

quit;

proc sql noprint;


create table header as
select trt01an, trt01a, count(distinct usubjid) as denom
from adsl
where trt01an ne . and saffl='Y'
group by trt01an,trt01a;

select denom into:n1-:n2


from header;
quit;

%put &n1 &n2;


data counts2;
merge counts header;
by trt01an trt01a;

length perc $50;


if section not in(4,5,7,8) then do;
if nmiss(smaln,denom)= 0 then perc=put(smaln, 3.)||put("
("||strip(put((smaln/denom)*100,5.1))||")",8. -r);
end;

if perc='' and sord ne 20.5 then perc=put(smaln,8.);


if perc='' and sord eq 20.5 then perc=put(smaln,9.1);
run;

proc sort data=counts2;by section sord text;


run;

proc transpose data=counts2 out=t_cnt prefix=trt;


by section sord text;
var perc;
id trt01an;
run;

****Section 7 for mean, median, min, max stats*******************************;

data hosp33;
set hosp3;
if hoendt<hostdt then delete;
run;
proc sort data=hosp33;by trt01an trt01a;run;
proc means data=hosp33 noprint min max median std mean;
by trt01an trt01a;
var hosp_stay_cat;

output out=duration(drop=_type_ _freq_) mean=mn stddev=sd median=md min=min max=max


/ autoname;
run;

****Section 8 for mean, median, min, max stats*******************************;


proc sort data=firsthospdays;by trt01an trt01a;run;
proc means data=firsthospdays noprint min max median std mean;
where tth ne .;
by trt01an trt01a;
var firsthospdays;

output out=tth_stat(drop=_type_ _freq_) mean=mn stddev=sd median=md min=min max=max


/ autoname;
run;

data duration;
set duration;
section=7;sord=23;
run;

data tth2;
set tth_stat;
section=8;sord=25;
run;

data section78;
merge duration tth2 ;
by section sord;
run;

data step1(drop=mn sd md min max);


set section78;
*n1=(put(n, 8.));
if not missing(mn) and not missing(sd) then
mn1=(put(mn,10.1)||' ('||strip(put(sd, 9.2)))||')';
if not missing(mn) and missing(sd) then
mn1=(put(mn, 10.1)||' (NE)');
if missing(mn) and missing(sd) then mn1=(put('NE',2.)||' (NE)');

md1=(put(md, 10.1));
if missing(md) then md1=put('NE',4.);

if not missing(min) and not missing(max) then


/*minmax=(put(min,best.)||', '||strip((put(max,best.))));*/
minmax=(put(min, 9.0)||', '||strip((put(max, 9.0))));

if missing(min) and missing(max) then minmax=right(put('NE ,NE',7.));

run;

proc sort data=step1;by section sord;


run;

*transposing data;
proc transpose data=step1 out=t_step1(rename=(_name_=text)) prefix=TRT ;
by section sord;
id trt01an;
var mn1 md1 minmax;
run;
proc sort;by section sord text;run;

data allset1;
merge t_cnt t_step1;
by section sord text;
run;
****Creating the frame of texts*******;

data frame;
length text $200;

section=3;sord=14.9;text='Number of patients with first hospitalization


starting:';output;
section=6;sord=20.9;text='Number of patients with days of hospitalization of[1][2]:
';output;
section=7;sord=21.9;text='Days of hospitalization (days) [1][2]';output;
section=8;sord=23.9;text='Time to start of first hospitalization (days)[2]';output;

run;

data allset2;
merge allset1 frame;
by section sord text;

if section=3 and sord=15 then do;


if text=' During month 1' then subord=.1;
else if text=' During month 2' then subord=.2;
else if text=' During month 3' then subord=.3;
else if text=' During month 4' then subord=.4;
else if text=' During month 5' then subord=.5;
else if text=' During month 6' then subord=.6;
else if text=' After month 6' then subord=.7;
else if text=' Prior to Day 1' then subord=.01;
end;
if section=6 and sord=21 then do;
if text=' 1 - 6 days' then subord=.1;
else if text=' 7 - 13 days' then subord=.2;
else if text=' 14 - 20 days' then subord=.3;
else if text=' ~{unicode 2265} 21 days' then subord=.4;
end;
if section in(7,8) then do;
if text='n' then do; text=' n';subord=.1;end;
else if text='mn1' then do; text=' Mean (SD)';subord=.2;end;
else if text='md1' then do; text=' Median';subord=.3;end;
else if text='minmax' then do; text=' Min, Max';subord=.4;end;

end;

if subord ne . then sord+subord;


run;

proc sort data=allset2;by section sord text;run;

data dummy;
length text $200 ;

text=' First hospitalization began before Day 1';sord=11;section=1;_name_ =


'perc';output;
text='Patients with >1 hospitalizations';; sord=14;section=2;_name_ =
'perc';output;
text=' During month 1' ; sord=15.1;section=3;_name_ = 'perc';output;
text=' During month 2' ; sord=15.2;section=3;_name_ = 'perc';output;
text=' During month 3' ; sord=15.3;section=3;_name_ = 'perc';output;
text=' During month 4' ; sord=15.4;section=3;_name_ = 'perc';output;
text=' During month 5' ; sord=15.5;section=3;_name_ = 'perc';output;
text=' During month 6' ; sord=15.6;section=3;_name_ = 'perc';output;
text=' After month 6' ; sord=15.7;section=3;_name_ = 'perc';output;
text=' Prior to Day 1' ; sord=15.01;section=3;_name_ = 'perc';output;

text=' 1 - 6 days' ; sord=21.1;section=6;_name_ = 'perc';output;


text=' 7 - 13 days' ; sord=21.2;section=6;_name_ = 'perc';output;
text=' 14 - 20 days' ; sord=21.3;section=6;_name_ = 'perc';output;;
/* text=' 11 - 13 days' ; sord=21.4;section=6;_name_ = 'perc';output;*/
/* text=' 14 - 20 days' ; sord=21.5;section=6;_name_ = 'perc';output;*/
/* text=' 21 - 27 days' ; sord=21.6;section=6;_name_ = 'perc';output;*/
text=' ~{unicode 2265} 21 days' ; sord=21.4;section=6;_name_ = 'perc';output;
proc sort;by sord text;
run;
proc sort data=allset2;by sord text;run;
data allset2_;
merge allset2 dummy;
by sord text;
run;;

proc sort data=allset2_;by section sord text;


run;

data result(rename=(_name_= name));


set allset2_ ;

by section sord text;

*trt1=strip(trt1);
*trt2=strip(trt2);

if section in(1,2,3) then pg=1;


else if section in(4,5,6) then pg=2;
else pg=3;
run;

data result_;
set result;
array nn trt:;
do over nn;
if NAME = 'perc' and nn = '' then nn = strip(put(0, 9. -r));;
end;
run;

DATA _NULL_;
CALL SYMPUT("FDATE",LEFT(PUT("&sysdate."d,YYMMDDN8.)));

RUN;

%xurtfsty();

ods rtf close;


options orientation=landscape nofmterr;
ods escapechar = '~';

%xurtfpt4(1, libref=tables);

%jprntd1(result_,t14_3_7_1_Hosp_all_SAS, %str( trt: text section sord),


%str(section sord pg), seq=1);

data _null_;
length lstfootl1 lstfootr1 lstfootl2 lstfootr2 $ 200;
lstfootl1="Source: Listing 16.3.7.1";
lstfootr1 = "Data Cutoff Date: &dcutdt.";
lstfootl2="Program Name:
/&CLNT./&PROJ./&TASK./%sysget(TASKDIR)/programs/tables/&SYSPARM..sas";
lstfootr2="Run Date: &sysdate9.(&SYSTIME)";

underln = repeat('_',161);
call symput('lstfootl1',lstfootl1);
call symput('lstfootr1',lstfootr1);
call symput('lstfootl2',lstfootl2);
call symput('lstfootr2',lstfootr2);
call symput('underln',underln);
run;

%jcgpgs1(9, pagesize_out, noheadskip=);

proc report data = result_ headskip headline split='|' nowd ls=161 ps=&ps. missing
spacing=2;
column pg section sord text trt1 trt2;

define pg / order noprint;


define section / order noprint;
define sord/ order order=internal noprint;

define text / /*order*/ flow " " style(header)=[just=left]


style(column)=[protectspecialchars=off cellwidth=2.0 in asis=on
just=left] width=52;

define trt1 / "AG-120+azacitidine|N=%left(&n1) " flow


style(header)=[just=c] style(column)=[protectspecialchars=off
cellwidth=0.75 in asis=on just=c] width=14;
define trt2 / "Placebo+azacitidine|N=%left(&n2) " flow
style(header)=[just=c] style(column)=[protectspecialchars=off
cellwidth=0.75 in asis=on just=c] width=14;

compute before section /style=[protectspecialchars=off asis=on just=left];


line @0 " " ;
endcomp;

break after pg / page;

footnote1 j=l h=9pt "&underln.";


footnote2 j=l h=9pt "The denominator used to calculate percentages is N, the
number of Subjects in the safety analysis set within each column.";
footnote3 j=l h=9pt "Only hospitalization days on or after day 1 are included in
the analysis. ";
footnote4 j=l h=9pt "[1] Days of hospitalization of each patient = total number
of days spent in the hospital from all hospital stays for each patient. For
patients with multiple hospital stays, only the non-overlapping days are counted.
Total days of hospitalization = sum of total days of hospitalization for all
patients.";
footnote5 j=l h=9pt "[2] Only hospitalization days on or after day 1 are
included in the analysis. Hospital stays started before day 1 will have day 1 as
hospitalization start date. Ongoing hospital stays will have data cut-off date as
hospitalization end date. ";
footnote6 j=l h=9pt "[3] Hospital days per days alive during day 1 - day 90 =
(Total days of hospitalization during day 1 - day 90)/(Total days alive during day
1 - day 90) * 100.";
footnote7 j=l h=9pt "&lstfootl1." j=r "&lstfootr1.";
footnote8 j=l h=9pt "&lstfootl2." j=r "&lstfootr2.";

run;

ods rtf close;


ods listing;

%xurtfpt4;

title;
footnote;

You might also like