Working with SAS Data Sets

Opening a SAS Data Set

Before you can access a SAS data set, you must first submit a command to open it. There are three ways to open a SAS data set:

USE SAS-data-set < VAR operand > < WHERE(expression) > ;

With Read access, you can use the FIND, INDEX, LIST, and READ statements with the data set.

  • To read and write to an existing data set, use the EDIT statement. The general form of the EDIT statement is as follows:

    EDIT SAS-data-set < VAR operand > < WHERE(expression) > ;

    This statement enables you to use both the reading statements (LIST, READ, INDEX, and FIND) and the writing statements (REPLACE, APPEND, DELETE, and PURGE).
  • To create a new data set, use the CREATE statement to open a new data set for both output and input. The general form of the CREATE statement is as follows:

    CREATE SAS-data-set < VAR operand > ;
    CREATE SAS-data-set FROM from-name
               < [COLNAME=column-name ROWNAME=row-name] > ;

    Use the APPEND statement to place the matrix data into the newly created data set. If you do not use the APPEND statement, the new data set has no observations.

  • If you want to list observations and create matrices from the data in the SAS data set named CLASS, you must first submit a statement to open the CLASS data set. Because CLASS already exists, specify the USE statement.

    Previous Page | Next Page | Top of Page