Writing a Report Program in Five Steps

Writing a report can be an iterative process. You will likely find that it takes several tries to produce the report you need. Before starting your report program, make sure you understand your data and the types of information that the report should convey. Do not concentrate on the style attributes of the report until you’re sure you can produce the basic output. Then after successfully establishing the structure of the report, add the formatting features that improve the look and readability of your report.

These five steps can guide you in writing your report programs.

1.
State the information that the report should convey. Write sentences that describe and explain the contents of your report.

2.
Sketch how the report should look. Consider these issues in planning your report:

What type of report is this–detail, summary, customized, multipanel, a combination of types?
What defines the columns of the report–variables, computed variables?
What defines the rows of the report–an observation, summaries of observations, groups of observations?
How should the rows be ordered?
What kind of annotation is needed in the report–customized lines, titles, footnotes?

3.
Understand your data. Consider these issues when you investigate the content and structure of your analysis data sets:

What data sets do you need to produce the report?
How are the analysis data sets structured? Run PROC CONTENTS or view the properties to review the attributes of the variables in the data sets and the characteristics of the data sets, such as size and sorting. List a few observations with PROC PRINT to see what the values look like. When producing a summary report, run PROC FREQ on the variables that define the categories in your reports to determine the number of levels and whether values should be grouped. This will help you predict the physical size of the final report. Consider whether PROC FORMAT would be useful in grouping the data. Run PROC MEANS to determine ranges of values.
Is the physical structure of the data set in the same orientation as the report? Do you need to reshape the data sets? What method should you use to reshape the data–DATA steps, PROC TRANSPOSE, output data set from a procedure?
Do you need to combine data sets? How should you combine data sets–MERGE or SET statements in DATA steps, PROC APPEND, PROC SQL?
Do you need to compute new variables? If so, should you do this before you execute the report-writing procedure? If you’re using PROC REPORT, you may not know the answer until you test your PROC REPORT step. When writing a DATA step to produce a report, you may be able to compute the new variables and produce the report in the same step.
Do you need to rearrange the order of the data for the report? You may not know the answer to this question until you select the report-writing procedure. Say, for example, that your goal is to produce a detail report with ordered rows. If you use PROC PRINT, your data set must be sorted or indexed in the proper order before you execute PROC PRINT. If you use PROC REPORT, you may not have to sort the data set before using the procedure. Options within PROC REPORT–the ORDER or GROUP option on the DEFINE statement and the ORDER= option on the PROC REPORT statement–will order the rows of your report.

4.
Select the report-writing procedure or decide to use a DATA step and, after reshaping the data sets as explained in Step 3, write the basic statements that construct the report. Ensure that your program can construct the basic layout of the report, and do not dwell on formatting the report (formatting columns, adding labels, adding style options, etc.). It may take several tries to achieve the required structure, and you may need to return to Step 3 to learn more about your data sets, reshape the data sets, or compute new variables. Refer to Table 1.2 for a list of which procedures perform best at which tasks.

5.
Add formatting features to the report. Consider whether to add these items to improve the look of your report:

SAS defined formats and user-defined formats
titles, footnotes, labels
customized lines
style attributes for fonts, spacing, borders, etc.
customized BY lines
summary lines
features specific to the output destination

Your final report program will likely be a hybrid of formatting features available within the procedure and those that can be supplied with ODS specifications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.249.141