10.1 - Basic List Reports

10.1 - Basic List Reports

In this section, we'll learn how to create three different basic list reports. In the first example, we'll create a basic list report of an entire SAS data set. In the second example, we'll create a basic list report of part of a SAS data set by selecting just a subset of the variables contained in the data set. In the last example, we'll create a basic list report of part of a SAS data set by selecting just those observations in the data set that meet a certain condition.

Example 10.2

The following SAS program creates a basic list report of the entire permanent SAS data set called stat480.penngolf:

LIBNAME stat480 'C:\Yourdrivename\stat480wc\sasndata\';
PROC REPORT data = stat480.penngolf NOWINDOWS;
   title 'Some Pennsylvania Golf Courses';
RUN;

Some Pennsylvania Golf Courses

ID

Name

Architect

Year

Type

Par

Yards

Slope

USGA

101

Toftrees

Ed Ault

1968

Resort

72

7018

134

74.3

102

Penn State Blue

William Park, Jr.

1921

Public

72

6525

128

72.0

103

Centre Hills

Alex Findlay

1921

Private

71

6392

128

71.2

104

Lewistown CC

 

.

Private

72

6779

125

72.3

105

State College Elks

Lowell Erdman

1973

SemiPri

71

6369

123

70.9

106

Park Hills CC

James Harrison

1966

SemiPri

70

6004

126

69.3

107

Sinking Valley CC

Ad Ault

1967

SemiPri

72

6755

132

73.4

108

Williamsport CC

A.W Tillinghast

1909

Private

71

6489

131

71.9

109

Standing Stone CC

Geoffrey Cornish

1973

SemiPri

70

6593

120

71.4

110

Bucknell GC

 

1960

SemiPri

70

6253

132

70.0

111

Mount Airy Lodge

Hal Purdy

1972

Resort

72

7123

140

74.3

The REPORT procedure contained in this code represents the most basic form of the procedure, in which the data set is specified and the NOWINDOWS option is used. Of course, you have to tell SAS the data set whose contents you want displayed. The NOWINDOWS option — also known as the NOWD option — tells SAS to display the report in the output window. If you don't specify the NOWINDOWS option, then SAS uses the WINDOWS option by default, which tells SAS to display the report in a special REPORT window (note, this has changed in the latest version of SAS and NOWINDOWS is now the default).

If you've already followed the directions in Example 10.1, and have thus run the program there, then you can simply launch this program, delete the LIBNAME statement, run  the SAS program, and review the output from the REPORT procedure.

If you haven't already followed the directions in Example 10.1, you'll need to download the stat480.penngolf data set by clicking on the link. After you've saved the data set in a convenient location on your computer, launch the SAS program, and edit the LIBNAME statement so that it reflects the location in which you saved the stat480.penngolf data set. Then, run  the SAS program, so that you have access to the data set throughout the lesson. Then, review the output from the REPORT procedure.

Upon reviewing the output, you should notice that all eleven of the observations and all nine of the variables contained in the stat480.penngolf data set are printed. As, you can see, by default, the variables appear in the order in which they occur in the data set. Oh, you might also note that the report continues across two pages because SAS can't fit it into one page as the PRINT procedure can. This has to do with the default width SAS allocates to each column. This is a column attribute that we'll learn how to modify in the next section.

Example 10.3

Rather than telling SAS to display the entire stat480.penngolf data set, the following SAS program uses the COLUMN statement to tell SAS to display just five of the columns — Name, Year, Type, Par, and Yards — in the order specified:

PROC REPORT data = stat480.penngolf NOWINDOWS HEADLINE;
     title 'Some Pennsylvania Golf Courses';
     column Name Year Type Par Yards;
RUN;

Some Pennsylvania Golf Courses

Name

Year

Type

Par

Yards

Toftrees

1968

Resort

72

7018

Penn State Blue

1921

Public

72

6525

Centre Hills

1921

Private

71

6392

Lewistown CC

.

Private

72

6779

State College Elks

1973

SemiPri

71

6369

Park Hills CC

1966

SemiPri

70

6004

Sinking Valley CC

1967

SemiPri

72

6755

Williamsport CC

1909

Private

71

6489

Standing Stone CC

1973

SemiPri

70

6593

Bucknell GC

1960

SemiPri

70

6253

Mount Airy Lodge

1972

Resort

72

7123

Launch and run  the SAS program, and review the output to convince yourself that just the requested subset of the data set has been displayed in the report. Oh, you might also want to take note of the effect of the HEADLINE option. As you can see, the HEADLINE option tells SAS to underline all of the column headings, as well as the spaces between the columns. It's a nice way to "prettify" your output!

Example 10.4

Again, rather than telling SAS to display the entire stat480.penngolf data set, the following SAS program uses:

  • the COLUMN statement to tell SAS to display just five of the columns — Name, Year, Type, Par, and Yards — in the order specified, and
  • the WHERE statement to tell SAS to display only those golf courses whose Type equals Private or Resort.

Here's the program:

PROC REPORT data = stat480.penngolf NOWINDOWS HEADSKIP;
     title 'Some Pennsylvania Golf Courses';
     column Name Year Type Par Yards;
	 where Type in ('Private', 'Resort');
RUN;

Some Pennsylvania Golf Courses

Name

Year

Type

Par

Yards

Toftrees

1968

Resort

72

7018

Centre Hills

1921

Private

71

6392

Lewistown CC

.

Private

72

6779

Williamsport CC

1909

Private

71

6489

Mount Airy Lodge

1972

Resort

72

7123

Launch and run  the SAS program, and review the output to convince yourself that just the requested subset of the data set has been displayed in the report. This time, you might want to take note of the effect of the HEADSKIP option. As you can see, the HEADSKIP option tells SAS to write a blank line beneath all of the column headings, as well as the spaces between the columns. If you use the HEADSKIP option in conjunction with the HEADLINE option, SAS writes a blank line beneath the underline. You might want to add the HEADLINE option to this code and re-run  it just so you can see the effect for yourself.


Legend
[1]Link
Has Tooltip/Popover
 Toggleable Visibility