Chapter Contents

Previous

Next
CREATE

CREATE



Creates a SAS/ACCESS descriptor file.

Required statement
Applies to: access descriptor or view descriptor


Syntax
Details
Access descriptors
View descriptors
Example

Syntax

CREATE libref.member-name.ACCESS | VIEW;

Details

The CREATE statement identifies the access descriptor or view descriptor that you want to create. This statement is required for creating a descriptor.

To create a descriptor, use a three-level name. The first level identifies the libref of the SAS data library where you will store the descriptor. You can store the descriptor in a temporary (WORK) or permanent SAS data library. The second level is the descriptor's name (member name). The third level is the type of SAS file: specify ACCESS for an access descriptor or VIEW for a view descriptor.

You can use the CREATE statement as many times as necessary in one procedure execution. That is, you can create multiple access descriptors, as well as one or more view descriptors based on these access descriptors, within the same execution of the ACCESS procedure. Or, you can create access descriptors and view descriptors in separate executions of the procedure.


Access descriptors

When you create an access descriptor, you must place statements or groups of statements in a certain order after the PROC ACCESS statement and its options, as listed below:

  1. CREATE statement for the access descriptor: this statement must always follow the PROC ACCESS statement if a descriptor is being created.

  2. Database connection statements: DBMS-specific statements for your DBMS. Information from database connection statements is stored in an access descriptor. Therefore, you do not repeat this information when you create view descriptors. See your DBMS chapter for information on database connection statements for your DBMS.

  3. TABLE statement and/or editing statements: ASSIGN, DROP, FORMAT, LIST, RENAME, RESET.

  4. Specify the RUN statement to execute the ACCESS procedure. If you specify QUIT instead of RUN, PROC ACCESS terminates without creating your descriptor. Alternately, you can specify another CREATE or UPDATE statement to execute the previous CREATE or UPDATE statement; your changes are saved when a new CREATE, UPDATE, RUN, or other SAS statement is executed.

The order of the statements within the database connection group does not matter. The order of the statements within the editing group sometimes matters; see the individual statement descriptions for any restrictions.

Note:   Altering a DBMS table that has descriptor files defined on it might invalidate these files or cause them to be outdated. If you re-create a table, add a new column to a table, or delete an existing column from a table, use the UDPATE statement to modify your descriptors to use the new information.  [cautionend]


View descriptors

You can create view descriptors and access descriptors in the same execution of the ACCESS procedure or in separate executions.

To create a view descriptor and the access descriptor on which it is based within the same PROC ACCESS execution, you must place the statements or groups of statements in a particular order after the PROC ACCESS statement and its options, as listed below:

  1. Create the access descriptor as described in Access descriptors, but do not include the RUN statement.

  2. CREATE statement for the view descriptor: this statement must follow the PROC ACCESS statements that created the access descriptor.

  3. Editing statements: SELECT, SUBSET, and UNIQUE are used only when creating view descriptors. FORMAT, LIST, RENAME, and RESET are used when creating both view and access descriptors. FORMAT, RENAME, and UNIQUE can be specified only when ASSIGN=NO is specified in the access descriptor referenced by this view descriptor. QUIT is also an editing statement but using it terminates PROC ACCESS without creating your descriptor.

    The order of the statements within this group usually does not matter; see the individual statement descriptions for any restrictions.

    Note:   You cannot use the DROP statement when you create a view descriptor. Instead, use SELECT to specify the columns you want.  [cautionend]

  4. Specify the RUN statement to execute the ACCESS procedure. If you specify QUIT instead of RUN, PROC ACCESS terminates without creating your descriptor. Alternately, you can specify another CREATE or UPDATE statement to execute the previous CREATE or UPDATE statement; your changes are saved when a new CREATE, UPDATE, RUN, or other SAS statement is executed.

To create a view descriptor based on an access descriptor that was created in a separate PROC ACCESS step, you specify the access descriptor's name in the ACCDESC= option in the new PROC ACCESS statement. You must specify the CREATE statement before any of the editing statements for the view descriptor.

If you create only one descriptor in a PROC step, the CREATE statement and its accompanying statements are checked for errors when you submit PROC ACCESS for processing. If you create multiple descriptors in the same PROC step, each CREATE statement (and its accompanying statements) is checked for errors as it is processed.

When the RUN statement is processed, all descriptors are saved if no errors are found. If errors are found, error messages are written to the SAS log, processing is terminated, and the descriptors are not saved. After you correct the errors, resubmit your statements.


Example

The following example creates an access descriptor ADLIB.EMPLOY on the Oracle Rdb table EMPLOYEES and a view descriptor VLIB.EMP1204 based on ADLIB.EMPLOY in the same PROC ACCESS step.

proc access dbms=rdb;

   /* create access descriptor  */

   create adlib.employ.access;     
   database='qa:[dubois]textile';
   table=employees;
   assign=no;
   list all;

   /* create view descriptor  */

   create vlib.emp1204.view;     
   select empid lastname hiredate salary dept 
   gender birthdate;
   format empid 6.
          salary dollar12.2
          jobcode 5.
          hiredate datetime9.
          birthdate datetime9.;
   subset where jobcode=1204;
run;

The following example creates a view descriptor VLIB.BDAYS from the ADLIB.EMPLOY access descriptor, which was created in the previous PROC ACCESS step.

proc access dbms=rdb accdesc=adlib.employ;
   create vlib.bdays.view;
   select empid lastname birthdate;
   format empid 6.
          birthdate datetime7.;
run;


Chapter Contents

Previous

Next

Top of Page

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