Previous Page | Next Page

Report Writing

Producing a Listing Report

A listing report displays data from a table. Using the Listing Report task, you can display all the data from a table, or a portion of the data, based on criteria that you specify. By following the instructions in this section, you can produce a report that shows the information for ranch-style homes from the HOUSES table. A listing report displays one line for each observation in the table.

Information on Ranch Style Houses Report

[Information on Ranch Style Houses Report]

A table is a collection of information arranged in columns and rows. A column is a set of data values that represents a particular type of data; for example, the price of all the houses. A row is a set of data values for the same item; for example, all the information about one house, such as price, style, square footage, and so on. Refer to Setting Up SAS Files for more information about tables, rows, and columns.


Setting Up the Report

  1. To create a listing report, you first set up the report by following this selection path: Tasks [arrow] Report Writing [arrow] ListingThe List a Table window appears.

    List a Table Window

    [List a Table Window]

  2. If the active table is SASUSER.HOUSES, then continue to the next step. Otherwise, select Table, and then select the SASUSER.HOUSES table. For more information on selecting tables, see Selecting a Table.

  3. If there is an active Subset Data selection (indicated with BY, WHERE, or ROWS next to Subset data), then clear the selection. For more information, see Clearing a Subset Data Selection.

  4. If other report selections exist (for example, Columns is not -ALL-), then selectFile [arrow] Newto clear these selections.

  5. To produce a report that lists all the data in the HOUSES table, selectRun [arrow] SubmitThe Listing Report appears in the Output window.

    Listing of HOUSES Table

    [Listing of HOUSES Table]

    The listing report is a quick way to get a list of all the data in your table. Note the different styles of the houses. For the sample report shown in Information on Ranch Style Houses Report, only the RANCH style houses are selected.

  6. If the report is wider or longer than the window, use the scroll bars or the FORWARD, BACKWARD, LEFT, and RIGHT function keys to look at the rest of the report. Refer to Using Function Keys for further information on function keys.

  7. After you have finished looking at the report, return to the List a Table window by using one of the following methods, depending on your operating environment:

    • Use the PREVWIND function key.

    • Click on the SAS/ASSIST window.

    Note:   Under some operating environments, if you are using the Output window and the report is longer than one display, the last display of the report is shown after you select Close once. In this case, select File and then Close again. The task window reappears.  [cautionend]


Subsetting the Data

To produce the report shown in Information on Ranch Style Houses Report, you need to subset and customize the report. Subset the data as follows:

  1. Select Subset data in the List a Table window. The Subset Data window appears.

    Subset Data Window

    [Subset Data Window]

    You subset the data if you want to produce a report that uses only some of the data in the table. For example, to produce the sample report shown in Information on Ranch Style Houses Report, you need to subset the data so that only data for ranch-style houses are used.

  2. Select WHERE clause. The Build a WHERE Clause to Subset the Current Data window appears.

    Build a WHERE Clause to Subset the Current Data Window

    [Build a WHERE Clause to Subset the Current Data Window]

    This window enables you to create a WHERE clause that specifies criteria for selecting rows. The rows that match the criteria in the WHERE clause are used in the report. For this example, you build a WHERE clause that selects only the houses for which the STYLE is RANCH.

    You subset the data by using one of the following methods:

    • You can type the WHERE clause directly by selecting Edit the WHERE clause and typing STYLE='RANCH' under Edit the current WHERE clause.

    • You can build the WHERE clause by making selections from this window. The items that are available for selection are highlighted while you build the WHERE clause. For example, when the Build a WHERE Clause window appears, only the Column, Constant, Function, NOT, and Opening parenthesis items are highlighted because these are the only items that can begin a WHERE clause.

  3. To build the WHERE clause using the items in the window, select Column from the Build a WHERE Clause window, and then select the STYLE column. For more information, see Selecting a Column.

  4. Select Comparison operator from the Build a WHERE Clause window. A window with a list of valid comparison operators appears.

    Select Data Window (Comparison Operators)

    [Select Data Window (Comparison Operators)]

  5. Select the equal operator from the Select Data window. The Build a WHERE Clause window reappears.

  6. There are two ways to specify a constant value. Use one of the following methods:

    • Select Look up constants. SAS/ASSIST software searches the column and presents a list of unique values in the Select Data window.

      Select Data Window (Look Up Constants)

      [Select Data Window (Look Up Constants)]

      Select RANCH and then select OK.

      Note:   Using Look up constants prevents you from making typing errors. However, it is more useful when the number of possible values is small than when the number of possible values is large.  [cautionend]

    • Select Constant from the Build a WHERE Clause window. The Enter a Character Constant window appears.

      Enter a Character Constant Window

      [Enter a Character Constant Window]

      To select the ranch-style houses, type RANCH in the Value field. Make sure RANCH is in uppercase because all of the style values are in uppercase in this sample data.

      Any time you use a character string for a constant value in a WHERE or BY clause, you need to make sure you use the exact case of the character string in the table. If the word ranch had been in lowercase in the HOUSES table, you would type ranch .

  7. Select OK. The Build a WHERE Clause window reappears. The WHERE clause that you built is shown under the WHERE clause being built item as shown in the following display.

    Completed WHERE Clause

    [Completed WHERE Clause]

    To make changes to the WHERE clause, select Edit the WHERE clause. You can then make changes to the column, comparison operator, and constant.

    Note that in certain operating environments, there is an additional option to Verify where clause against data. If you select this option, then SAS checks to see if there are any rows that meet the conditions of your WHERE clause. If your table is very large, then this verification can take a long time.

  8. Select OK and then Goback to return to the List a Table window. Notice that the value in the Subset data field is WHERE. This value indicates that a WHERE clause is being used to subset your data.


Adding Titles

You can customize the report by adding titles and footnotes, changing the page dimensions, and selecting headings. Follow these directions to add a title to your report:

  1. Follow this selection path: Edit [arrow] TitlesThe Titles window appears.

    Titles Window

    [Titles Window]

  2. Select Title 1 from the Titles window. The Title 1 window appears.

    Title 1 Window

    [Title 1 Window]

  3. In the Title 1 field, type the title exactly as you want it to appear on the report. For this report, type the title Information on Ranch Style Houses . Select OK twice to return to the List a Table window.

    Note:   Because the same set of titles and footnotes is used for all SAS/ASSIST tasks, the titles and footnotes that you specified most recently in your SAS/ASSIST session are used unless you change or reset them. If a title already exists when you open the Titles window, then type the new title over the old title.  [cautionend]


Running the Report

After you have finished setting up the report, you can run the report.

  1. Follow this selection path: Run [arrow] SubmitThe report appears in the Output window.

    Information on Ranch Style Houses Report

    [Information on Ranch Style Houses Report]

    This report shows all the data for the ranch-style houses in the HOUSES table.

  2. If the report is wider or longer than the window, use the scroll bars or the FORWARD, BACKWARD, LEFT, and RIGHT function keys to look at the report.


Printing the Report

If you do not want to print the report, go to the next section. To print the report, follow these instructions.

Note:   To ensure that row and column separators and boxed tabular reports will be printed legibly when using the standard forms characters, you must use these resources:

Characters that are used in standard forms are specified by using the FORMCHAR system option. Printer fonts are specified by using the SYSPRINTFONT system option. Character and font specifications vary according to your operating environment and your print methods. If you run under the Windows operating environment, see the FORMCHAR and SYSPRINTFONT system options in the companion documentation. For all other operating environments, see these system options in SAS Language Reference: Dictionary.  [cautionend]

  1. Follow this selection path from the Output window: File [arrow] PrintDepending on your operating environment, the output may be sent directly to your default printer, or you may see the Print window, where you can select printing options.

    Print Window

    [Print Window]

  2. Make sure the name of your default printer (or some other printer of your choosing) appears in the Default Printer field in the Print window. If it does not, then select Setup and choose your printer from the list that appears. If you do not know which printer to choose, then contact the SAS Support Consultant at your site.

  3. To print the current report, select Print in the Print window. The report is sent to your printer, and a message appears in the Output window that indicates how many lines were printed.


Exiting This Task

When you have finished viewing or printing your report, return to the List a Table window by using one of the following methods, depending on your operating environment:

To return to the WorkPlace menu or move on to another task, follow the directions in Exiting a Task.

Previous Page | Next Page | Top of Page