SlideShare a Scribd company logo
1 of 10
Download to read offline
*****************************************************************
*Project ***********
*****************************************************************
********
*PROGRAM NAME: TABLE8
*PROGRAM LOCATION: ***********
*PROGRAM PURPOSE: create Table8-Other hospitalization analyses at 90
days
*SAS VERSION: 9.4
*AUTHOR: Cynthia Guan
*DATE: 05-11-2015
*****************************************************************
********;
*call the library;
options nodate mprint symbolgen mtrace mlogic nonumber nofmterr;
%macro libclear;
%if %sysfunc(libref(library))=0 %then /*libref function returns
0 when an existing libref*/
%sysfunc(libname(library)); /*libname function clears a
libref when no other arguments included*/
%mend;
%libclear;
filename library '******************';
options sasautos=(library);
%include library;
%library;
data work.hospanls;
set anlysds.hospanls;
run;
proc sort data=hospanls;
by subject;
run;
%macro unhosp(var,order);
proc genmod data=hospanls;
model &var=trtgrp /offset=log dist=poi link=log;
ods output parameterestimates=poss_&var;
run;
data temp_&var;
length order $50;
set poss_&var;
where parameter="Trtgrp";
order="&order";
keep probchisq order;
run;
%mend;
%unhosp(var=cv_hdays,order=0);
%unhosp(var=any_hdays,order=2);
%unhosp(var=HF_year,order=4);
%unhosp(var=ucv_hdays,order=6);
%unhosp(var=all_year,order=8);
%macro adhosp(var,order);
proc genmod data=hospanls;
class trtgrp(param=ref ref=last) nyha(param=ref ref=first)
gender(param=ref ref=first);
model &var=trtgrp nyha gender age __ef_/offset=log dist=poi
link=log;
estimate 'trtgrp adj rate' int 1 trtgrp 1 0/exp;
estimate 'control adj rate' int 1 trtgrp 0 1/exp;
ods output parameterestimates=_poss&var
estimates=estima&var;
run;
data _temp&var;
length order $50;
set _poss&var;
where Parameter='Trtgrp';
order="&order";
keep probchisq order;
run;
%mend;
%adhosp(var=cv_hdays,order=1);
%adhosp(var=any_hdays,order=3);
%adhosp(var=HF_year,order=5);
%adhosp(var=ucv_hdays,order=7);
%adhosp(var=all_year,order=9);
data temp_pval;
merge temp_cv_hdays temp_any_hdays temp_HF_year temp_ucv_hdays
temp_all_year;
by order;
type=0;
run;
data _temp_pval;
merge _tempcv_hdays _tempany_hdays _tempHF_year _tempucv_hdays
_tempall_year;
by order;
type=0;
run;
data temp;
set temp_pval _temp_pval;
by order;
run;
%macro num(dts,vari,group,order);
proc means data=&dts;
class &group;
var &vari;
output out=n&vari n=n&vari;
run;
data n&vari;
set n&vari;
if &group='' then &group=3;
run;
*convert to character;
data cn&vari;
length c&vari $35 order $50;
format n&vari 6.;
set n&vari;
type=0;
if n&vari=. then c&vari=0;
else c&vari=compress(put(n&vari,comma5.));
order="&order";
drop _TYPE_ _FREQ_ n&vari;
run;
proc sort data=cn&vari;
by &group;
run;
*get the mean of subject by each group;
proc means data=&dts noprint;
class &group;
var &vari;
output out=mean&vari mean=m&vari std=sd&vari;
run;
*add a number to the total group;
data mean&vari;
set mean&vari;
if &group="" then &group=3;
run;
*convert to character;
data cmean&vari;
length c&vari $35 order $50;
set mean&vari;
type=1;
if sd&vari ne . and m&vari ne . then
c&vari=compress(put(m&vari,6.2)||'('||put(sd&vari,6.2)||')');
else if m&vari=. and sd&vari=. then c&vari='0(0)';
else if sd&vari=. then c&vari=compbl(put(m&vari,6.2)||'(0)');
else if m&vari=. then c&vari=compbl('(0)'||put(sd&vari,6.2));
order="&order";
drop _type_ _freq_ m&vari sd&vari;
run;
proc sort data=cmean&vari;
by &group;
run;
*get the median, min and max of subjects by each group;
proc means data=&dts noprint;
class &group;
var &vari;
output out=mmm&vari min=min&vari max=max&vari median=med&vari;
run;
*add a number to the trtgrp of the total group;
data mmm&vari;
set mmm&vari;
if &group="" then &group=3;
run;
*convert to character;
data cmmm&vari;
length c&vari $35 order $50;
format min&vari max&vari 5.;
set mmm&vari;
type=2;
if min&vari= . then c&vari='0(0,0)';
else
c&vari=compress(put(med&vari,6.2)||'('||put(min&vari,6.2)||','||p
ut(max&vari,6.2)||')');
order="&order";
drop min&vari max&vari med&vari _TYPE_ _FREQ_ ;
run;
proc sort data=cmmm&vari;
by &group;
run;
data merge&vari;
merge cmean&vari cn&vari cmmm&vari;
by type;
format trtgrp trtgrpf.;
run;
proc transpose data=merge&vari out=tr&vari(drop=_name_);
by type order;
id &group;
var c&vari;
run;
%mend;
%num(dts=hospanls,vari=cv_hdays,group=trtgrp,order=0);
%num(dts=hospanls,vari=any_hdays,group=trtgrp,order=2);
%num(dts=hospanls,vari=HF_year,group=trtgrp,order=4);
%num(dts=hospanls,vari=ucv_hdays,group=trtgrp,order=6);
%num(dts=hospanls,vari=all_year,group=trtgrp,order=8);
data ntemp_;
merge trcv_hdays trany_hdays trHF_year trucv_hdays trall_year;
by order;
run;
%macro _num(dts,vari,group,order);
proc means data=&dts;
class &group;
var &vari;
output out=_n&vari n=n&vari;
run;
data _n&vari;
set _n&vari;
if &group='' then &group=3;
run;
*convert to character;
data _cn&vari;
length c&vari $35 order $50;
format n&vari 6.;
set _n&vari;
type=0;
if n&vari=. then c&vari=0;
else c&vari=compress(put(n&vari,comma5.));
order="&order";
drop _TYPE_ _FREQ_ n&vari;
run;
proc sort data=_cn&vari;
by &group;
run;
*get the mean of subject by each group;
proc means data=&dts noprint;
class &group;
var &vari;
output out=_mean&vari mean=m&vari std=sd&vari;
run;
*add a number to the total group;
data _mean&vari;
set _mean&vari;
if &group="" then &group=3;
run;
*convert to character;
data _cmean&vari;
length c&vari $35 order $50;
set _mean&vari;
type=1;
if sd&vari ne . and m&vari ne . then
c&vari=compress(put(m&vari,6.2)||'('||put(sd&vari,6.2)||')');
else if m&vari=. and sd&vari=. then c&vari='0(0)';
else if sd&vari=. then c&vari=compbl(put(m&vari,6.2)||'(0)');
else if m&vari=. then c&vari=compbl('(0)'||put(sd&vari,6.2));
order="&order";
drop _type_ _freq_ m&vari sd&vari;
run;
proc sort data=_cmean&vari;
by &group;
run;
*get the median, min and max of subjects by each group;
proc means data=&dts noprint;
class &group;
var &vari;
output out=_mmm&vari min=min&vari max=max&vari
median=med&vari;
run;
*add a number to the trtgrp of the total group;
data _mmm&vari;
set _mmm&vari;
if &group="" then &group=3;
run;
*convert to character;
data _cmmm&vari;
length c&vari $35 order $50;
format min&vari max&vari 5.;
set _mmm&vari;
type=2;
if min&vari= . then c&vari='0(0,0)';
else
c&vari=compress(put(med&vari,6.2)||'('||put(min&vari,6.2)||','||p
ut(max&vari,6.2)||')');
order="&order";
drop min&vari max&vari med&vari _TYPE_ _FREQ_ ;
run;
proc sort data=_cmmm&vari;
by &group;
run;
data _merge&vari;
merge _cmean&vari _cn&vari _cmmm&vari;
by type;
format trtgrp trtgrpf.;
run;
proc transpose data=_merge&vari out=_tr&vari(drop=_name_);
by type order;
id &group;
var c&vari;
run;
%mend;
%_num(dts=hospanls,vari=cv_hdays,group=trtgrp,order=1);
%_num(dts=hospanls,vari=any_hdays,group=trtgrp,order=3);
%_num(dts=hospanls,vari=HF_year,group=trtgrp,order=5);
%_num(dts=hospanls,vari=ucv_hdays,group=trtgrp,order=7);
%_num(dts=hospanls,vari=all_year,group=trtgrp,order=9);
data _ntemp_;
merge _trcv_hdays _trany_hdays _trHF_year _trucv_hdays
_trall_year;
by order;
run;
data temp;
merge ntemp_ _ntemp_ temp_pval _temp_pval;
by order;
run;
data otherhos;
length order $50;
set temp;
format order hosdaysf. type typef.;
run;
options orientation=landscape ls=132 ps=49 missing=' ';
ods rtf file="*********************" style=minimal;
ods escapechar="^";
Title1 j=l f=arial h=8pt '***************';
Title2 j=l f=arial h=8pt '*************' j=r "page ^{pageof}";
title3 j=c f=arial h=10pt 'Table 8.';
title4 j=c f=arial h=10pt "ITT Analysis Set";
title5 j=c f=arial h=10pt "Other Hospitalization Analyses at 90 days";
footnote1 j=l f=arial h=8pt "Note:All subjects are randomized.";
footnote2 j=l f=arial h=8pt "*P-values are based on Poisson
regression";
footnote3 j=l f=arial h=8pt "#-Unadjusted *-Adjusted for
age,gender,LVEF and NYHA class at baseline";
footnote4 j=r h=6pt "Executed:&sysdate9 &systime";
proc report data=otherhos nowindows headskip missing split='|'
spacing=2
style(header)=[font_face=arial font_size=8pt
font_weight=bold BORDERBOTTOMSTYLE=solid borderbottomcolor=black
backgroundcolor=white]
style(column)=[font_face=arial font_size=8pt
BORDERBOTTOMSTYLE=solid]
style(summary)=[font_face=arial font_size=8pt]
style(report)=[font_face=arial font_size=8pt rules=groups
frame=hsides asis=on cellspacing=2 cellpadding=2];
column order type treatment control total probchisq;
define order/group order=data left ' ' flow " "
style(column)=[cellwidth=25%];
define type/left ' ' flow "Type" style(column)=[cellwidth=15%];
define Treatment/ center flow "Treatment Group"
style(column)=[cellwidth=15%];
define control/center flow "Placebo Group"
style(column)=[cellwidth=15%];
define total/center flow "Total Group"
style(column)=[cellwidth=15%];
define probchisq/group order=data center flow "p-value"
style(column)=[cellwidth=10%];
quit;
ods rtf close;
proc datasets library=work kill;
quit;
Table 8
ITT Sample
Other hospitalization analyses at 90 days
Total
(N) Treatment
(N)
Control
(N)
P-value
Number of days hospitalized for CV causes# xx xx xx x.xxx
Number of days hospitalized for CV cause* xx xx xx x.xxx
Number of days hospitalized for any cause# xx xx xx x.xxx
Number of days hospitalized for any cause* xx xx xx x.xxx
HFH per life year# xx xx xx x.xxx
HFH per life year* xx xx xx x.xxx
Unplanned CV hospitalizations per life year# xx xx xx x.xxx
Unplanned CV hospitalizations per life year* xx xx xx x.xxx
All cause hospitalizations per life year # xx xx xx x.xxx
All cause hospitalizations per life year * xx xx xx x.xxx
# unadjusted * adjusted for age, gender, hospitalization within the prior 30d, LVEF at baseline, NYHA Class at baseline

More Related Content

What's hot

vfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent testsvfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent testsFrank Kleine
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking Sebastian Marek
 
Aksharica - 004 (अक्षरिका - ००४)
Aksharica - 004 (अक्षरिका - ००४)Aksharica - 004 (अक्षरिका - ००४)
Aksharica - 004 (अक्षरिका - ००४)Rajesh Koirala
 
Aksharica - 082 (अक्षरिका - ०८२)
Aksharica - 082 (अक्षरिका - ०८२)Aksharica - 082 (अक्षरिका - ०८२)
Aksharica - 082 (अक्षरिका - ०८२)Rajesh Koirala
 
11 Things About 11gr2
11 Things About 11gr211 Things About 11gr2
11 Things About 11gr2afa reg
 

What's hot (6)

vfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent testsvfsStream - a better approach for file system dependent tests
vfsStream - a better approach for file system dependent tests
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking
 
Aksharica - 004 (अक्षरिका - ००४)
Aksharica - 004 (अक्षरिका - ००४)Aksharica - 004 (अक्षरिका - ००४)
Aksharica - 004 (अक्षरिका - ००४)
 
Aksharica - 082 (अक्षरिका - ०८२)
Aksharica - 082 (अक्षरिका - ०८२)Aksharica - 082 (अक्षरिका - ०८२)
Aksharica - 082 (अक्षरिका - ०८२)
 
كتاب ظلال العرش برواية ورش
كتاب ظلال العرش برواية ورشكتاب ظلال العرش برواية ورش
كتاب ظلال العرش برواية ورش
 
11 Things About 11gr2
11 Things About 11gr211 Things About 11gr2
11 Things About 11gr2
 

Similar to SAS code sample

java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdfDngTin307322
 
寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)均民 戴
 
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docxodiliagilby
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeMagnify Analytic Solutions
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapRodolphe Quiédeville
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxcarliotwaycave
 
Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsDr P Deepak
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docxSHIVA101531
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shellady36
 
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いRetrieva inc.
 
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docxProgram 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docxwkyra78
 
A Little Bit Of Insight 2011
A Little Bit Of Insight 2011A Little Bit Of Insight 2011
A Little Bit Of Insight 2011Marrianne Garbutt
 
Guía de ingreso a plataforma presmad
Guía de ingreso a plataforma presmadGuía de ingreso a plataforma presmad
Guía de ingreso a plataforma presmadMiguel Rivera
 
2017 investors day_v21.4_toq4_compressed
2017 investors day_v21.4_toq4_compressed2017 investors day_v21.4_toq4_compressed
2017 investors day_v21.4_toq4_compressedRockwellAutomationIR
 

Similar to SAS code sample (20)

Event
EventEvent
Event
 
Java
JavaJava
Java
 
java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdf
 
寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事 (Git 部分節錄)
 
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx
__MACOSX._assign3assign3.DS_Store__MACOSXassign3._.D.docx
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTapTests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
 
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docxInstruction1. Please read the two articles. (Kincheloe part 1 &.docx
Instruction1. Please read the two articles. (Kincheloe part 1 &.docx
 
Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statistics
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
 
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docxProgram 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
Program 8 C++newproblems.txt12333142013KristinBrewer1032823.docx
 
Ip project
Ip projectIp project
Ip project
 
A Little Bit Of Insight 2011
A Little Bit Of Insight 2011A Little Bit Of Insight 2011
A Little Bit Of Insight 2011
 
Guía de ingreso a plataforma presmad
Guía de ingreso a plataforma presmadGuía de ingreso a plataforma presmad
Guía de ingreso a plataforma presmad
 
2017 investors day_v21.4_toq4_compressed
2017 investors day_v21.4_toq4_compressed2017 investors day_v21.4_toq4_compressed
2017 investors day_v21.4_toq4_compressed
 

SAS code sample

  • 1. ***************************************************************** *Project *********** ***************************************************************** ******** *PROGRAM NAME: TABLE8 *PROGRAM LOCATION: *********** *PROGRAM PURPOSE: create Table8-Other hospitalization analyses at 90 days *SAS VERSION: 9.4 *AUTHOR: Cynthia Guan *DATE: 05-11-2015 ***************************************************************** ********; *call the library; options nodate mprint symbolgen mtrace mlogic nonumber nofmterr; %macro libclear; %if %sysfunc(libref(library))=0 %then /*libref function returns 0 when an existing libref*/ %sysfunc(libname(library)); /*libname function clears a libref when no other arguments included*/ %mend; %libclear; filename library '******************'; options sasautos=(library); %include library; %library; data work.hospanls; set anlysds.hospanls; run; proc sort data=hospanls; by subject; run; %macro unhosp(var,order); proc genmod data=hospanls; model &var=trtgrp /offset=log dist=poi link=log; ods output parameterestimates=poss_&var; run;
  • 2. data temp_&var; length order $50; set poss_&var; where parameter="Trtgrp"; order="&order"; keep probchisq order; run; %mend; %unhosp(var=cv_hdays,order=0); %unhosp(var=any_hdays,order=2); %unhosp(var=HF_year,order=4); %unhosp(var=ucv_hdays,order=6); %unhosp(var=all_year,order=8); %macro adhosp(var,order); proc genmod data=hospanls; class trtgrp(param=ref ref=last) nyha(param=ref ref=first) gender(param=ref ref=first); model &var=trtgrp nyha gender age __ef_/offset=log dist=poi link=log; estimate 'trtgrp adj rate' int 1 trtgrp 1 0/exp; estimate 'control adj rate' int 1 trtgrp 0 1/exp; ods output parameterestimates=_poss&var estimates=estima&var; run; data _temp&var; length order $50; set _poss&var; where Parameter='Trtgrp'; order="&order"; keep probchisq order; run; %mend; %adhosp(var=cv_hdays,order=1); %adhosp(var=any_hdays,order=3); %adhosp(var=HF_year,order=5); %adhosp(var=ucv_hdays,order=7); %adhosp(var=all_year,order=9);
  • 3. data temp_pval; merge temp_cv_hdays temp_any_hdays temp_HF_year temp_ucv_hdays temp_all_year; by order; type=0; run; data _temp_pval; merge _tempcv_hdays _tempany_hdays _tempHF_year _tempucv_hdays _tempall_year; by order; type=0; run; data temp; set temp_pval _temp_pval; by order; run; %macro num(dts,vari,group,order); proc means data=&dts; class &group; var &vari; output out=n&vari n=n&vari; run; data n&vari; set n&vari; if &group='' then &group=3; run; *convert to character; data cn&vari; length c&vari $35 order $50; format n&vari 6.; set n&vari; type=0; if n&vari=. then c&vari=0; else c&vari=compress(put(n&vari,comma5.)); order="&order"; drop _TYPE_ _FREQ_ n&vari; run; proc sort data=cn&vari;
  • 4. by &group; run; *get the mean of subject by each group; proc means data=&dts noprint; class &group; var &vari; output out=mean&vari mean=m&vari std=sd&vari; run; *add a number to the total group; data mean&vari; set mean&vari; if &group="" then &group=3; run; *convert to character; data cmean&vari; length c&vari $35 order $50; set mean&vari; type=1; if sd&vari ne . and m&vari ne . then c&vari=compress(put(m&vari,6.2)||'('||put(sd&vari,6.2)||')'); else if m&vari=. and sd&vari=. then c&vari='0(0)'; else if sd&vari=. then c&vari=compbl(put(m&vari,6.2)||'(0)'); else if m&vari=. then c&vari=compbl('(0)'||put(sd&vari,6.2)); order="&order"; drop _type_ _freq_ m&vari sd&vari; run; proc sort data=cmean&vari; by &group; run; *get the median, min and max of subjects by each group; proc means data=&dts noprint; class &group; var &vari; output out=mmm&vari min=min&vari max=max&vari median=med&vari; run; *add a number to the trtgrp of the total group; data mmm&vari; set mmm&vari;
  • 5. if &group="" then &group=3; run; *convert to character; data cmmm&vari; length c&vari $35 order $50; format min&vari max&vari 5.; set mmm&vari; type=2; if min&vari= . then c&vari='0(0,0)'; else c&vari=compress(put(med&vari,6.2)||'('||put(min&vari,6.2)||','||p ut(max&vari,6.2)||')'); order="&order"; drop min&vari max&vari med&vari _TYPE_ _FREQ_ ; run; proc sort data=cmmm&vari; by &group; run; data merge&vari; merge cmean&vari cn&vari cmmm&vari; by type; format trtgrp trtgrpf.; run; proc transpose data=merge&vari out=tr&vari(drop=_name_); by type order; id &group; var c&vari; run; %mend; %num(dts=hospanls,vari=cv_hdays,group=trtgrp,order=0); %num(dts=hospanls,vari=any_hdays,group=trtgrp,order=2); %num(dts=hospanls,vari=HF_year,group=trtgrp,order=4); %num(dts=hospanls,vari=ucv_hdays,group=trtgrp,order=6); %num(dts=hospanls,vari=all_year,group=trtgrp,order=8); data ntemp_; merge trcv_hdays trany_hdays trHF_year trucv_hdays trall_year; by order; run;
  • 6. %macro _num(dts,vari,group,order); proc means data=&dts; class &group; var &vari; output out=_n&vari n=n&vari; run; data _n&vari; set _n&vari; if &group='' then &group=3; run; *convert to character; data _cn&vari; length c&vari $35 order $50; format n&vari 6.; set _n&vari; type=0; if n&vari=. then c&vari=0; else c&vari=compress(put(n&vari,comma5.)); order="&order"; drop _TYPE_ _FREQ_ n&vari; run; proc sort data=_cn&vari; by &group; run; *get the mean of subject by each group; proc means data=&dts noprint; class &group; var &vari; output out=_mean&vari mean=m&vari std=sd&vari; run; *add a number to the total group; data _mean&vari; set _mean&vari; if &group="" then &group=3; run; *convert to character; data _cmean&vari; length c&vari $35 order $50;
  • 7. set _mean&vari; type=1; if sd&vari ne . and m&vari ne . then c&vari=compress(put(m&vari,6.2)||'('||put(sd&vari,6.2)||')'); else if m&vari=. and sd&vari=. then c&vari='0(0)'; else if sd&vari=. then c&vari=compbl(put(m&vari,6.2)||'(0)'); else if m&vari=. then c&vari=compbl('(0)'||put(sd&vari,6.2)); order="&order"; drop _type_ _freq_ m&vari sd&vari; run; proc sort data=_cmean&vari; by &group; run; *get the median, min and max of subjects by each group; proc means data=&dts noprint; class &group; var &vari; output out=_mmm&vari min=min&vari max=max&vari median=med&vari; run; *add a number to the trtgrp of the total group; data _mmm&vari; set _mmm&vari; if &group="" then &group=3; run; *convert to character; data _cmmm&vari; length c&vari $35 order $50; format min&vari max&vari 5.; set _mmm&vari; type=2; if min&vari= . then c&vari='0(0,0)'; else c&vari=compress(put(med&vari,6.2)||'('||put(min&vari,6.2)||','||p ut(max&vari,6.2)||')'); order="&order"; drop min&vari max&vari med&vari _TYPE_ _FREQ_ ; run; proc sort data=_cmmm&vari;
  • 8. by &group; run; data _merge&vari; merge _cmean&vari _cn&vari _cmmm&vari; by type; format trtgrp trtgrpf.; run; proc transpose data=_merge&vari out=_tr&vari(drop=_name_); by type order; id &group; var c&vari; run; %mend; %_num(dts=hospanls,vari=cv_hdays,group=trtgrp,order=1); %_num(dts=hospanls,vari=any_hdays,group=trtgrp,order=3); %_num(dts=hospanls,vari=HF_year,group=trtgrp,order=5); %_num(dts=hospanls,vari=ucv_hdays,group=trtgrp,order=7); %_num(dts=hospanls,vari=all_year,group=trtgrp,order=9); data _ntemp_; merge _trcv_hdays _trany_hdays _trHF_year _trucv_hdays _trall_year; by order; run; data temp; merge ntemp_ _ntemp_ temp_pval _temp_pval; by order; run; data otherhos; length order $50; set temp; format order hosdaysf. type typef.; run; options orientation=landscape ls=132 ps=49 missing=' '; ods rtf file="*********************" style=minimal;
  • 9. ods escapechar="^"; Title1 j=l f=arial h=8pt '***************'; Title2 j=l f=arial h=8pt '*************' j=r "page ^{pageof}"; title3 j=c f=arial h=10pt 'Table 8.'; title4 j=c f=arial h=10pt "ITT Analysis Set"; title5 j=c f=arial h=10pt "Other Hospitalization Analyses at 90 days"; footnote1 j=l f=arial h=8pt "Note:All subjects are randomized."; footnote2 j=l f=arial h=8pt "*P-values are based on Poisson regression"; footnote3 j=l f=arial h=8pt "#-Unadjusted *-Adjusted for age,gender,LVEF and NYHA class at baseline"; footnote4 j=r h=6pt "Executed:&sysdate9 &systime"; proc report data=otherhos nowindows headskip missing split='|' spacing=2 style(header)=[font_face=arial font_size=8pt font_weight=bold BORDERBOTTOMSTYLE=solid borderbottomcolor=black backgroundcolor=white] style(column)=[font_face=arial font_size=8pt BORDERBOTTOMSTYLE=solid] style(summary)=[font_face=arial font_size=8pt] style(report)=[font_face=arial font_size=8pt rules=groups frame=hsides asis=on cellspacing=2 cellpadding=2]; column order type treatment control total probchisq; define order/group order=data left ' ' flow " " style(column)=[cellwidth=25%]; define type/left ' ' flow "Type" style(column)=[cellwidth=15%]; define Treatment/ center flow "Treatment Group" style(column)=[cellwidth=15%]; define control/center flow "Placebo Group" style(column)=[cellwidth=15%]; define total/center flow "Total Group" style(column)=[cellwidth=15%]; define probchisq/group order=data center flow "p-value" style(column)=[cellwidth=10%]; quit;
  • 10. ods rtf close; proc datasets library=work kill; quit; Table 8 ITT Sample Other hospitalization analyses at 90 days Total (N) Treatment (N) Control (N) P-value Number of days hospitalized for CV causes# xx xx xx x.xxx Number of days hospitalized for CV cause* xx xx xx x.xxx Number of days hospitalized for any cause# xx xx xx x.xxx Number of days hospitalized for any cause* xx xx xx x.xxx HFH per life year# xx xx xx x.xxx HFH per life year* xx xx xx x.xxx Unplanned CV hospitalizations per life year# xx xx xx x.xxx Unplanned CV hospitalizations per life year* xx xx xx x.xxx All cause hospitalizations per life year # xx xx xx x.xxx All cause hospitalizations per life year * xx xx xx x.xxx # unadjusted * adjusted for age, gender, hospitalization within the prior 30d, LVEF at baseline, NYHA Class at baseline