Report Macros An Introduction Using An Example. REPORT TO GENERATE.

25
Report Macros An Introduction Using An Example

Transcript of Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Page 1: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Report Macros

An Introduction Using An Example

Page 2: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD 364 (4.5%) 365 (4.4%) 1.02 (0.88 - 1.18) 0.771

MI (Fatal/NF) 133 (1.6%) 166 (2.0%) 0.82 (0.65 - 1.03) 0.089

Stroke (Fatal/NF) 133 (1.6%) 118 (1.4%) 1.15 (0.90 - 1.48) 0.265

CVD Death 152 (1.9%) 143 (1.7%) 1.09 (0.87 - 1.37) 0.471

Any CVD Hospitalization 793 (9.7%) 775 (9.3%) 1.05 (0.95 - 1.16) 0.307

Revascularization 163 (2.0%) 166 (2.0%) 1.01 (0.82 - 1.26) 0.913

TIA 89 (1.1%) 105 (1.3%) 0.87 (0.66 - 1.15) 0.330

Angina 202 (2.5%) 190 (2.3%) 1.09 (0.89 - 1.33) 0.389

Heart Failure 126 (1.5%) 100 (1.2%) 1.30 (1.00 - 1.69) 0.051

Hypertension 22 (0.3%) 18 (0.2%) 1.26 (0.67 - 2.34) 0.474

Renal Failure 27 (0.3%) 34 (0.4%) 0.81 (0.49 - 1.35) 0.426

REPORT TO GENERATE

Page 3: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD 364 (4.5%) 365 (4.4%) 1.02 (0.88 - 1.18) 0.771

MI (Fatal/NF) 133 (1.6%) 166 (2.0%) 0.82 (0.65 - 1.03) 0.089

Stroke (Fatal/NF) 133 (1.6%) 118 (1.4%) 1.15 (0.90 - 1.48) 0.265

CVD Death 152 (1.9%) 143 (1.7%) 1.09 (0.87 - 1.37) 0.471

Any CVD Hospitalization 793 (9.7%) 775 (9.3%) 1.05 (0.95 - 1.16) 0.307

Revascularization 163 (2.0%) 166 (2.0%) 1.01 (0.82 - 1.26) 0.913

TIA 89 (1.1%) 105 (1.3%) 0.87 (0.66 - 1.15) 0.330

Angina 202 (2.5%) 190 (2.3%) 1.09 (0.89 - 1.33) 0.389

Heart Failure 126 (1.5%) 100 (1.2%) 1.30 (1.00 - 1.69) 0.051

Hypertension 22 (0.3%) 18 (0.2%) 1.26 (0.67 - 2.34) 0.474

Renal Failure 27 (0.3%) 34 (0.4%) 0.81 (0.49 - 1.35) 0.426

REPORT TO GENERATE

These data come from proc means

Page 4: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD 364 (4.5%) 365 (4.4%) 1.02 (0.88 - 1.18) 0.771

MI (Fatal/NF) 133 (1.6%) 166 (2.0%) 0.82 (0.65 - 1.03) 0.089

Stroke (Fatal/NF) 133 (1.6%) 118 (1.4%) 1.15 (0.90 - 1.48) 0.265

CVD Death 152 (1.9%) 143 (1.7%) 1.09 (0.87 - 1.37) 0.471

Any CVD Hospitalization 793 (9.7%) 775 (9.3%) 1.05 (0.95 - 1.16) 0.307

Revascularization 163 (2.0%) 166 (2.0%) 1.01 (0.82 - 1.26) 0.913

TIA 89 (1.1%) 105 (1.3%) 0.87 (0.66 - 1.15) 0.330

Angina 202 (2.5%) 190 (2.3%) 1.09 (0.89 - 1.33) 0.389

Heart Failure 126 (1.5%) 100 (1.2%) 1.30 (1.00 - 1.69) 0.051

Hypertension 22 (0.3%) 18 (0.2%) 1.26 (0.67 - 2.34) 0.474

Renal Failure 27 (0.3%) 34 (0.4%) 0.81 (0.49 - 1.35) 0.426

REPORT TO GENERATE

These data come from proc phreg

Page 5: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');

Step 1Starting the Report

This statement begins the report and defines the file the report will be written.

Page 6: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');

%colset(30 15 15 20 10);

Step 2Defining the Columns

This statement defines the report columns. There will be 5 columns. The size of the column 1 will be twice that of column 2 and 3. Values are only in reference to each other.

Page 7: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

TITLE

WILL GO HERE

Column 1 Col 2 Col 3 Col 4 Col 5

RESULT

Page 8: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

%move('Number and Percent of Selected Cardiovascular Events by Treatment Group<br> And Hazard Ratio(Experimental/Standard)from Cox Regression Analyses', col=1-5, line=1,fontweight=bold, fontsize=12pt);

Step 3Placing Text Labels

Macro move places text strings on the report. This is one long text string (placed in quotes). The <br> will be interpreted by html as a break. The text will be centered over columns 1-5. Lines are in reference to other line statements. We choose line = 1 since this our title. The text will be bold and will be size 12 point.

Page 9: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Column 1 Col 2 Col 3 Col 4 Col 5

RESULT

Page 10: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

%move('Number of Patients<br>With Event', col=2-3, line=9, fontweight=bold);

%move('Cox Regression Analyses<br>Experimental/Standard', col=4-5, line=9,fontweight=bold);

%move('Experimental':'Standard':'HR (95% CI)':'P-value', col=2.5,line=11, fontweight=bold);

Step 3Placing More Text Labels

Here are additional move statements. The 3rd statement moves 4 text strings which are separated by colons. The strings are moved to columns 2 through 5 (4 different columns). Line numbers are in reference to each other. The first two statements will move text to the same line and will be before the text from the 3rd statement.

Page 11: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Experimental Standard HR (95% CI) P-value

Column 1 Col 2 Col 3 Col 4 Col 5

RESULT

Page 12: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

%move('Endpoint', col=1, center=n, line=11, fontstyle=italic, fontweight=bold);

%move('Primary CVD ':'Any CVD Hospitalization', col=1, center=n, line=14 19, fontstyle=italic, fontweight=bold);

Step 3Placing More Text Labels

Here are move statements to place headings in column 1. The text will be left justified (center = n). In the second statement a gap between lines 14 and 19 to leave room for the specific causes to be placed in the next move.

Page 13: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD

Any CVD Hospitalization

Column 1 Col 2 Col 3 Col 4 Col 5

RESULT

Page 14: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

%move('MI (Fatal/NF)': 'Stroke (Fatal/NF)': 'CVD Death': 'Revascularization': 'TIA': 'Angina': 'Heart Failure': 'Hypertension': 'Renal Failure', col=1, center=2, line=15L3 20L6, indent=1);

Step 3Placing More Text Labels

This moves 9 text strings all to column 1. Line = 15L3 is a shortcut to line = 15 16 17. Indent = 1 means to indent the strings.

Page 15: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD

MI (Fatal/NF)

Stroke (Fatal/NF)

CVD Death

Any CVD Hospitalization

Revascularization

TIA

Angina

Heart Failure

Hypertension

Renal Failure

Column 1 Col 2 Col 3 Col 4 Col 5

RESULT

Page 16: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

set out1;%nmove(sum1-sum22 m1-m22, col=2 3, line=15L3 20L6, scaler=1 100,combine=y, fmt=5.0 5.1, fchar=2P);

Step 4Placing Statistics to Report

The set statement brings in the statistics for the counts and means from the dataset out1. These contain statistics for both groups and for all 11 events. Thus there are 22 sums, 22 means, etc. Later on we will show how this dataset was created. We want to put the sum and mean in the same cell so we use the option combine=y. The fchar option indicated how to combine the two numbers in the cell. Fchar=2P means to use the format xx (xx%) which is typical for formatting N followed by a percent. The fmt has two values on how to format the first and second number. The scaler option tells SAS to multiply the values by the values supplied before writing them to the report. Here the means will be multiplied by 100 to give a percent.

Page 17: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD 364 (4.5%) 365 (4.4%)

MI (Fatal/NF) 133 (1.6%) 166 (2.0%)

Stroke (Fatal/NF) 133 (1.6%) 118 (1.4%)

CVD Death 152 (1.9%) 143 (1.7%)

Any CVD Hospitalization 793 (9.7%) 775 (9.3%)

Revascularization 163 (2.0%) 166 (2.0%)

TIA 89 (1.1%) 105 (1.3%)

Angina 202 (2.5%) 190 (2.3%)

Heart Failure 126 (1.5%) 100 (1.2%)

Hypertension 22 (0.3%) 18 (0.2%)

Renal Failure 27 (0.3%) 34 (0.4%)

Column 1 Col 2 Col 3 Col 4 Col 5

Page 18: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');%colset(30 15 15 20 10);

set out2;%nmove(r1-r14 l1-l14 u1-u14, col=4, combine=y, fmt=5.2 5.2 5.2, fchar=3);

%nmove(p1-p14 , col=5, fmt=6.3);

Step 4Placing Statistics to Report

The set statement brings in the statistics from the cox-regression analyses. Statistics included are the relative risk and the lower and upper 95% confidence intervals and the p-values. There are 11 items for each corresponding to the 11 analyses. In the first nmove statement three statistics are placed in each cell (RR and lower and upper CI). They are combined using the format associated with fchar=3 which displays the first number followed by the second and third in parenthesis. The last nmove statement displays the pvalues for testing the RR=1, displayed to 3 decimal places.

Page 19: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Number and Percent of Selected Cardiovascular Events by Treatment Group

And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses

Number of Patients

With Event

Cox Regression Analyses

Experimental/Standard

Endpoint Experimental Standard HR (95% CI) P-value

Primary CVD 364 (4.5%) 365 (4.4%) 1.02 (0.88 - 1.18) 0.771

MI (Fatal/NF) 133 (1.6%) 166 (2.0%) 0.82 (0.65 - 1.03) 0.089

Stroke (Fatal/NF) 133 (1.6%) 118 (1.4%) 1.15 (0.90 - 1.48) 0.265

CVD Death 152 (1.9%) 143 (1.7%) 1.09 (0.87 - 1.37) 0.471

Any CVD Hospitalization 793 (9.7%) 775 (9.3%) 1.05 (0.95 - 1.16) 0.307

Revascularization 163 (2.0%) 166 (2.0%) 1.01 (0.82 - 1.26) 0.913

TIA 89 (1.1%) 105 (1.3%) 0.87 (0.66 - 1.15) 0.330

Angina 202 (2.5%) 190 (2.3%) 1.09 (0.89 - 1.33) 0.389

Heart Failure 126 (1.5%) 100 (1.2%) 1.30 (1.00 - 1.69) 0.051

Hypertension 22 (0.3%) 18 (0.2%) 1.26 (0.67 - 2.34) 0.474

Renal Failure 27 (0.3%) 34 (0.4%) 0.81 (0.49 - 1.35) 0.426

Column 1 Col 2 Col 3 Col 4 Col 5

Page 20: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Getting the Statistics

• PROC MEANS– Get number and percent of each event for each

group

• PROC PHREGP– Get relative risks, CIs, p-values from Cox-

regression

• Macros breakdn and phregp run these procs and gather the needed statistics

Page 21: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

PROC MEANS DATA=lifetab; CLASS cgroup; VAR primary mi str cvddth allcvd corevas tia angina chf acchyp renalf;

PROC PHREG DATA=lifetab ; MODEL tprimary*PRIMARY(0) = group /TIES=breslow RL; STRATA soc cstrata;

PROC PHREG DATA=lifetab ; MODEL tmi*mi(0) = group /TIES=breslow RL; STRATA soc cstrata;RUN;

Page 22: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Obtaining the Summary Statistics

• Computes summary statistics for each variable in var by each level in group

• Stores statistics in one observation dataset out1 (M1-M22 contains means)

%let evlist = primary mi str cvddth allcvd corevas tia angina chf acchyp renalf ;

%breakdn (data=temp, class= group 2, var=&evlist, out=out1)

Page 23: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

Obtaining Statistics From PHREG

• Performs PHREG for each variable in dlist with independent variables in ilist

• Factor indicates which independent variable(s) statistics are requested

• Out names the one observation SAS dataset which contains p-values

• P-values are named P1-P11

%phregp (data=temp, dlist=&evlist, strata=country, tlist=&tmlist, ilist=group, factor=group, out=out2)

Page 24: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

libname here '.';

data lifetab; set here.coxreg;run;

%let evlist = primary mi str cvddth allcvd corevas tia angina chf acchyp renalf ;%let tmlist = tprimary tmi tstr tcvddth tallcvd tcorevas ttia tangina tchf tacchyp trenalf ;

%breakdn(data=lifetab, class= cgroup 2, var=&evlist, out=out1);

%phregp(data=lifetab, dlist = &evlist, strata=soc cstrata, tlist= &tmlist, ilist=group, factor=group, out = out2);

PROGRAM PART 1

Page 25: Report Macros An Introduction Using An Example. REPORT TO GENERATE.

%wreport(htmlfile='example.html');

%colset(30 15 15 20 10);

%move('Number and Percent of Selected Cardiovascular Events by Treatment Group<br>' 'And Hazard Ratio (Experimental/Standard) from Cox Regression Analyses', col=1-0, line=3, fontweight=bold, fontsize=12pt);%move('Number of Patients<br>With Event', col=2-3, line=9, fontweight=bold);%move('Cox Regression Analyses<br>Experimental/Standard', col=4-0, line=9, fontweight=bold);%move('Experimental':'Standard':'HR (95% CI)':'P-value', col=2.0,line=11, fontweight=bold);%move('Endpoint', col=1, center=2, line=11, u=1, fontstyle=italic, fontweight=bold);%move('Primary CVD ':'Any CVD Hospitalization', col=1, center=2, line=14 19, fontstyle=italic, fontweight=bold);%move('MI (Fatal/NF)':'Stroke (Fatal/NF)':'CVD Death':'Revascularization': 'TIA':'Angina':'Heart Failure':'Hypertension':'Renal Failure', col=1, center=2, line=15L3 20L6, indent=1);

set out2;%nmove(r1-r11 L1-L11 u1-u11, col=4, line=14L4 19L7, combine=y, fmt=5.2 5.2 5.2, fchar=3);%nmove(p1-p11 , col=5, fmt=6.3);

set out1;%nmove(sum1-sum22 m1-m22, col=2 3, scaler=1 100, combine=y, fmt=5.0 5.1, fchar=2P);

stop;run;%makehtml;

PROGRAM PART 2