space
Previous Page | Next Page

SAS/ACCESS Descriptor Files

Creating Descriptor Files

Access and view descriptor files are created by using the ACCESS procedure. You can create these files by using one PROC ACCESS step or multiple separate PROC ACCESS steps. This section shows how to create descriptor files in one PROC ACCESS step. Within a step, you can define multiple descriptor files of the same type or of different types.

Examples for creating the access descriptor MYLIB.EMPLOYE and the view descriptors VLIB.EMPPOS and VLIB.EMPSKIL by executing separate PROC ACCESS steps are provided in Example Programs.

Note:   When you execute a separate PROC ACCESS step to create a view descriptor, you must use the ACCDESC= option to specify an existing access descriptor from which the view descriptor will be created.   [cautionend]

The most common way to use the PROC ACCESS statements, especially when using batch mode, is to create an access descriptor and one or more view descriptors based on this access descriptor in a single execution of PROC ACCESS. For example, in the program that follows, first, you create the access descriptor MYLIB.EMPLOYE. Then, you create the two view descriptors VLIB.EMPPOS and VLIB.EMPSKIL. In the section that immediately follows this example program, each statement is explained in the order in which it appears in the program.

proc access dbms=s2k;
   create mylib.employe.access;
      database=employee; 
      s2kpw=demo mode=multi;
      assign=yes;
      drop c110 c120;
      rename forename=firstnme office_e=phone
             yearsofe=years gender=sex
             degree_c=degree;
      length firstnme=13 lastname=13 c101=16;
      list all;

   create vlib.emppos.view;
      select lastname firstnme position departme manager;
      subset "order by lastname";
      list all;

   create vlib.empskil.view;
      select c2 c3 c201 c203;
      subset "ob skilltyp";
      s2kpw=demo mode=multi;
      list view;
run;

proc access dbms=s2k;

invokes the ACCESS procedure for the SAS/ACCESS interface to SYSTEM 2000.

create mylib.employe.access;

identifies the access descriptor, MYLIB.EMPLOYE, that you want to create. The libref MYLIB must be associated with the SAS library before you can specify it in the CREATE statement.

database=employee

indicates that this access descriptor is for the database EMPLOYEE.

s2kpw=demo mode=multi;

specifies the password DEMO (which is required to access the database definition), and indicates that the database is in the Multi-User environment.

assign=yes;

generates unique SAS variable names based on the first 8 non-blank characters of the item names. Variable names and attributes can be changed in this access descriptor but not in any view descriptors that are created from this access descriptor.

drop c110 c120;

marks the records associated with the C-numbers C110 and C120 as non-display. Because these C-numbers represent records, all the items in each record are marked as non-display. Therefore, none of the items in the two records associated with these numbers appear in any view descriptor created from this access descriptor.

rename forename=firstnme office_e=phone yearsofe=years gender=sex degree_c=degree;

renames the default SAS variable names associated with the SAS names FORENAME, OFFICE_E, YEARSOFE, GENDER, and DEGREE_C. You specify the default SAS variable name on the left side of the equal sign (=) and the new name on the right side of the equal sign. Because the ASSIGN=YES statement was specified earlier, any view descriptors created from this access descriptor automatically use the new SAS variable names.

length firstnme=13 lastname=13 c101=16;

changes the field width for the items associated with FIRSTNME and LASTNAME to 13 characters and the field width for the item associated with C-number C101 (the SAS name POSITION) to 16 characters.

list all;

lists the access descriptor's item identifier numbers, C-numbers, SAS variable names, SAS formats, SAS informats, and SAS variable lengths. The list also includes any associated information specified in the BYKEY statement. Items that have been dropped from display (by using the DROP statement) have *NON-DISPLAY* next to them. The list is written to the SAS log.

create vlib.emppos.view;

writes the access descriptor to the library associated with MYLIB and identifies the view descriptor, VLIB.EMPPOS, that you want to create. The libref VLIB must be associated with a SAS library before you can specify it in this statement.

select lastname firstnme position departme manager;

selects the items associated with the SAS names LASTNAME, FIRSTNME, POSITION, DEPARTME, and MANAGER for inclusion in the view descriptor. The SELECT statement is required to create the view unless a RENAME, FORMAT, INFORMAT, LENGTH, or BYKEY statement is specified.

subset "order by lastname";

specifies that you want SYSTEM 2000 to order (or sort) output data set by last name. Use SYSTEM 2000 syntax in the SUBSET statement. For more information, see the QUEST Language and System-Wide Commands, Version 12 manual.

list all;

lists all the available item identifier numbers, C-numbers, SAS variable names, SAS formats, SAS informats, and SAS variable lengths on which the view descriptor is based. The list also includes any associated information specified in a BYKEY statement and selection criteria specified in the view descriptor. Items that have been dropped from the display have *NON-DISPLAY* next to them. Items that have been selected for the view have *SELECTED* next to them. The list is written to the SAS log.

create vlib.empskil.view;

writes the first view descriptor to the library associated with VLIB and identifies the next view descriptor, VLIB.EMPSKIL, that you create in this example.

select c2 c3 c201 c203;

selects the four items associated with the C-numbers C2, C3, C201, and C203 for inclusion in the view descriptor. The SELECT statement is required to create the view unless a RENAME, FORMAT, INFORMAT, LENGTH, or BYKEY statement is specified.

subset "ob skilltyp";

specifies that you want the observations to be sorted by skill type. See SUBSET Statement (Optional) for syntax information.

s2kpw=demo mode=multi;

specifies the password required to access the data and indicates the database is in the Multi-User environment. This information is stored in the view descriptor. To override this password or to specify a SYSTEM 2000 password for the view descriptor VLIB.EMPPOS that omits the S2KPW statement, you can use the S2KPW data set option. For more information, see Overriding Options.

list view;

lists the item identifier numbers, the C-numbers, the SAS variable names, the SAS formats, the SAS informats, and the SAS variable lengths that have been selected for the view descriptor. The list also includes any associated information specified in a BYKEY statement and selection criteria specified in the view descriptor. The list is written to the SAS log.

run;

writes the last view descriptor and runs the program.

space
Previous Page | Next Page | Top of Page