Order a data set by categories and list the observations. Write information that is constant for a category in the page titles rather than in columns. Each row in the report presents information about one observation.
Project FeederWatch Counts for Ten Observation Periods in Minnesota during 2002-2003 Counts for Site MN1001 Site Description: Medium (1,001-4,000 sq ft /101-375 sq m) in landscaped yard (with lawn and plantings) Community: Rural with a population of 5,001 to 25,000 Ever Species Seen P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 American crow **** 0 0 0 1 2 0 2 0 0 0 American goldfinch **** 2 2 3 6 9 7 6 8 7 6 American robin **** 1 20 1 0 0 0 1 0 0 3 American tree sparrow 0 0 0 0 0 0 0 0 0 0 Black-capped chickadee **** 3 2 2 2 1 1 2 2 1 2 Blue jay **** 2 2 1 4 2 2 1 4 3 2 Boreal chickadee 0 0 0 0 0 0 0 0 0 0 Brown creeper 0 0 0 0 0 0 0 0 0 0 Chipping sparrow **** 0 0 0 0 0 0 0 0 1 0 Common grackle **** 0 0 0 0 0 0 0 0 0 5 Common redpoll 0 0 0 0 0 0 0 0 0 0 Cooper's hawk 0 0 0 0 0 0 0 0 0 0 Dark-eyed junco **** 1 9 1 2 3 2 5 2 20 4 Downy woodpecker **** 3 2 2 2 3 3 6 3 4 6 European starling **** 0 0 0 0 0 0 0 0 4 5 Fox sparrow 0 0 0 0 0 0 0 0 0 0 Hairy woodpecker **** 0 0 1 3 2 2 1 0 1 1 House finch **** 3 0 0 0 0 0 0 0 2 2 House sparrow **** 20 30 20 20 20 20 20 20 10 20 Loggerhead shrike 0 0 0 0 0 0 0 0 0 0 Mallard 0 0 0 0 0 0 0 0 0 0 Mourning dove **** 0 0 0 0 0 0 0 1 0 1 Northern cardinal **** 2 2 0 1 3 2 2 2 3 2 Norther flicker **** 0 0 0 0 0 0 0 2 0 0 Northern shrike 0 0 0 0 0 0 0 0 0 0 Pileated woodpecker **** 0 0 0 1 1 0 0 1 0 0 Pine siskin 0 0 0 0 0 0 0 0 0 0 Purple finch **** 1 0 0 0 0 0 0 0 0 0 Red-breasted nuthatch 0 0 0 0 0 0 0 0 0 0 Reb-bellied woodpecker **** 0 1 1 1 1 1 1 1 1 1 Red-winged blackbird 0 0 0 0 0 0 0 0 0 0 Rock dove 0 0 0 0 0 0 0 0 0 0 Sharp-shinned hawk 0 0 0 0 0 0 0 0 0 0 Song sparrow **** 0 0 0 0 0 0 1 0 0 0 Tufted titmouse 0 0 0 0 0 0 0 0 0 0 White-breasted nuthatch **** 2 1 1 1 1 1 2 1 2 1 White-throated sparrow 0 0 0 0 0 0 0 0 0 0 Key to Ten Observation Periods: 1: 09nov2002-22nov2002 2: 23nov2002-06dec2002 3: 07dec2002-20dec2002 4: 21dec2002-03jan2003 5: 04jan2003-17jan2003 6: 18jan2003-31jan2003 7: 01feb2003-14feb2003 8: 15feb2003-28feb2003 9: 01mar2003-14mar2003 10: 15mar2003-28mar2003 |
Data Set | FEEDERBIRDS |
Featured Step | PROC PRINT |
Featured Step Statements and Options | PROC PRINT statement: LABEL option BY statement |
Formatting Features | OPTIONS statement: BYLINE/NOBYLINE, MISSING, and CENTER options TITLE statement with #BYVAL |
A Closer Look | Working with #BYVAL, #BYVAR, and #BYLINE when Customizing Titles |
When you want to list the observations in a data set by categories, and the values of several of the variables for a category are constant, you can place the constant information in the titles. By doing so, you make more room on the report page for information that varies within a category.
This example lists observations from the FEEDERBIRDS data set. This data set is a random sample of observations taken from a Cornell Laboratory of Ornithology data set that manages the records in the Project FeederWatch Citizen Science program. The sample contains records of the bird species seen and numbers counted at bird feeders during the 2002-2003 winter season in Minnesota.
Each observation in the data set corresponds to the maximum number of birds of one species seen at one time during ten observation periods. The data set is ordered by site ID. Several characteristics of the site are stored in the data set. These descriptions are constant for each site and their values are printed in the titles of the report. The program uses the #BYVAL feature of the TITLE statement in conjunction with the SAS system option NOBYLINE to place the site characteristics in the titles. The NOBYLINE option suppresses the BY line that normally appears in output produced with BY-group processing,
PROC PRINT lists the observations in the FEEDERBIRDS data set. If you use the BY statement and the NOBYLINE option, PROC PRINT always starts a new page for each BY group. This behavior ensures that if you create customized BY lines by putting BY-group information in a title and you suppress the default BY lines with NOBYLINE, the information in the titles matches the report on the pages.
The report that follows lists the counts for two of the ten sites in the sample data set.
A Closer Look |
When your PROC steps include a BY statement, you can customize your titles by taking advantage of the #BYVAL, #BYVAR, and #BYLINE features. These three features insert text at the position you place them in your TITLE statements.
The BYLINE/NOBYLINE SAS option controls the automatic printing of BY lines. Submit
options nobyline;
to turn off the BYLINE option before using the #BYVAL, #BYVAR, or #BYLINE features. As with other SAS options, NOBYLINE remains in effect until you reset it with
options byline;
Table 2.3 describes the #BYVAL, #BYVAR, and #BYLINE features.
Feature | Specification | Action |
---|---|---|
#BYVAL | #BYVALn | Replaces #BYVAL in the text string with the current value of the nth BY variable in the BY statement. |
#BYVAL(variable-name) | Replaces #BYVAL in the text string with the current value of the BY variable whose name is enclosed in parentheses. | |
#BYVAR | #BYVARn | Replaces #BYVAR in the text string with the name or label of the nth BY variable in the BY statement. Use the variable name only if the variable does not have a label. |
#BYVAR(variable-name) | Replaces #BYVAR in the text string with the name or label of the BY variable whose name is enclosed in parentheses in the BY statement. Use the variable name only if the variable does not have a label. | |
#BYLINE | Replaces #BYLINE in the text string with the entire BY line. |
When writing TITLE statements, terminate either of the two types of #BYVAL specifications and the two types of #BYVAR specifications with a delimiting character, such as a space or other nonalphanumeric character.
If you want the #BYVAL or #BYVAR substitution to be followed immediately by other text and not the delimiter, terminate the #BYVAL or #BYVAR specification with a trailing dot, just as you would with macro variables.
BY statement processing. See “BY Statement” in the “Statements” section of SAS 9.1 Language Reference: Dictionary, and “Statements with the Same Function in Multiple Procedures” in the “Concepts” section of Base SAS 9.1 Procedures Guide.
The BYLINE/NOBYLINE SAS system options. See “SAS System Options” in SAS 9.1 Language Reference: Dictionary.
Inserting BY-group information in titles. See “Creating Titles that Contain BY-Group Information” in the “Fundamental Concepts for Using Base SAS Procedures” section of Base SAS 9.1 Procedures Guide.
PROC PRINT reference, usage information, and additional examples. See “The PRINT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.
18.224.109.21