Chapter Contents

Previous

Next
Getting Started with the SAS System Using SAS/ASSIST Software

Defining a New Column


Instructions

  1. To define a new column, follow this selection path:

    Tasks
    [arrow]
    Data Management
    [arrow]
    Subset/Copy
    The Subset or Copy a Table window appears.

    Subset or Copy a Table Window

    [IMAGE]

    When you define a new column, use Subset/Copy because the existing table is copied and the newly defined column is created to generate the output table.

  2. If the active table is SASUSER.HOUSES, 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 other report selections exist (for example, column names are listed for Define new columns), follow this selection path to clear these selections:

    File
    [arrow]
    New

  4. Select Output data from the Subset or Copy a Table window. The Output Table or View window appears.

    Output Table or View Window

    [IMAGE]

    An output table enables you to store the data with the new column separate from the original data.

  5. In the Table/View field, type HOUSCOST as the name of the output table in which you want to store the data with the new column. See SAS Tables for details on naming SAS tables.

    Note:   Use Replace if existing to replace the data in a table or view of the same name. Otherwise, you get an error message that the table already exists and you must enter a new table name.  [cautionend]

  6. You can store the data temporarily or permanently. For this example, store the data temporarily.

  7. You can store the data with the new column either as a table or as a view. For this example, store the data as a table.

  8. Select OK. The Subset or Copy a Table window reappears.

  9. Select Define new columns from the Subset or Copy a Table window. The Define or Modify a Column window appears.

    Define or Modify a Column Window

    [IMAGE]

  10. In the Column field, type FOOTCOST as the name of the new column. See SAS Tables for details on naming columns.

  11. Select Numeric as the type of the column.

    A column can be character or numeric. If a column is defined as character, it can contain letters, numbers, special characters, and symbols, but it cannot be used in arithmetic calculations. If a column is defined as numeric, it can contain only numbers, decimal points, plus signs, and minus signs, and it can be used in arithmetic calculations.

  12. In the Label field, type Cost per Square Foot. A label can be up to 40 characters, and it can be printed instead of, or in addition to, the column name in certain tasks.

  13. Select Format. The Select Numeric Format window appears.

    Select Numeric Format Window

    [IMAGE]

    A format is a pattern that the SAS System uses to determine how a column value should be displayed. The SAS System provides a set of standard formats and also enables you to define your own custom formats. For example, the DOLLARw.d default format displays the amount 1200 as $1,200. For more information on formats, refer to SAS Language Reference: Dictionary.

  14. Select the DOLLARw.d format. The Specify Format Widths window appears with the default definition for the selected format.

    Specify Format Widths Window

    [IMAGE]

  15. Select OK to accept the defaults of 10 for the format width and 0 for the number of digits to the right of the decimal point. The Define or Modify a Column window reappears.

  16. Select Initialize from the Define or Modify a Column window. The Enter Numeric Expression window appears. This window enables you to define (initialize) the new column.

    Enter Numeric Expression

    [IMAGE]

    For this example, you can determine the cost per square foot by building the arithmetic expression of price divided by square feet (PRICE/SQFEET). The cost per square foot is calculated for each house and stored in the new column called FOOTCOST. You can build the expression by using one of the methods listed below.

  17. To build the expression by using the items in the window, select Column from the Enter Numeric Expression window. Select the PRICE column. For more information on selecting columns, refer to Selecting a Column.

  18. Select the division symbol (/).

  19. Select Column again, and then select the SQFEET column the same way you selected the PRICE column in step 17. The Enter Numeric Expression window reappears.

  20. Select OK. The Define or Modify a Column window reappears with the new column defined.

    Definition of the FOOTCOST Column

    [IMAGE]

    Select OK. The Define New Columns window appears with information about the new column.

    Define New Columns Window

    [IMAGE]

    Select OK again. The Subset or Copy a Table window reappears.

  21. To copy the data into the new table and generate the new column, follow this selection path:

    Run
    [arrow]
    Submit
    The data from the HOUSES table is copied into the HOUSCOST table, and the new column FOOTCOST is created. The new table is shown in a tabular format.

    HOUSCOST Table

    [IMAGE]

  22. When you finish looking at the new table, follow this selection path to return to the Subset or Copy a Data Set window:

    File
    [arrow]
    Close


Exiting This Task

When you are ready to return to the WorkPlace menu or move on to another task, follow the directions in Exiting a Task.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.