Chapter Contents

Previous

Next
SAS/ACCESS Software for PC File Formats: Reference

ACCESS Procedure: DIF Specifics

ACCESS Procedure Reference describes the generic options and procedure statements that enable you to create access descriptors, view descriptors, and SAS data files from PC file format data. The following section describes the PC file-specific statements you use in the SAS/ACCESS interface to DIF files.


ACCESS Procedure Statements for DIF Files

To create an access descriptor, you use the DBMS=DIF option and the database-description statements PATH=, DIFLABEL, and SKIPROWS. These statements supply DIF-specific information to the SAS System, and must immediately follow the CREATE statement. In addition to the database-description statements, you can use optional editing statements when you create an access descriptor. These editing statements must follow the database-description statements.

Database-description statements are only required when you create access descriptors. Because the DIF information is stored in an access descriptor, you do not need to repeat this information when you create view descriptors.

The SAS/ACCESS interface to DIF uses the following procedure statements:

PROC ACCESS options;
CREATE <libref.>member-name.ACCESS | VIEW;
UPDATE <libref.>member-name.ACCESS | VIEW;
PATH= 'path-and-filename<.DIF>' | <'>filename<'>| fileref;
DIFLABEL;
SKIPROWS <=> number-of-rows-to-skip;
ASSIGN | AN <=> YES | NO;
DROP <'>column-identifier-1<'><...<'>column-identifier-n<'>>;
FORMAT <'>column-identifier-1<'><=>SAS-format-name-1
<...<'>column-identifier-n<'><=> SAS-format-name-n>;
LIST <ALL | VIEW | <'>column-identifier<'>>;
RENAME <'>column-identifier-1<'> <=> SAS-variable-name-1
<...<'>column-identifier-n<'> <=> SAS-variable-name-n>;
RESET ALL | <'>column-identifier-1<'><...<'>column-identifier-n<'>>;
SELECT ALL | <'>column-identifier-1<'> <...<'>column-identifier-n<'>>;
SUBSET selection criteria ;
TYPE <'>column-identifier-1<'><=> C | N
<...column-identifier-n <=> C | N>;
UNIQUE <=> YES | NO;
RUN;

The QUIT statement is also available in PROC ACCESS. However, its use causes the procedure to terminate. QUIT is used most often in the interactive line and noninteractive modes to exit the procedure without exiting SAS.

DIFLABEL
indicates whether variable names are generated from the columns in the first row. If you omit this statement, variable names that are generated are based on the columns' placement in the first row. That is, the SAS System labels each column as COL0, COL1, COL2, and so on. These labels become the names of SAS variables in the access descriptor.

If you specify DIFLABEL, the ACCESS procedure reads column labels from the first row of the DIF file and uses them as the SAS variable names in the access descriptor. You provide the DIF file column labels; they are not the letters (for example, A, B, and so on) that identify the columns in a worksheet. If you specify DIFLABEL, the SKIPROWS statement automatically changes to 1.

Always specify DIFLABEL after the PATH= statement and before any editing statements. When you update a descriptor, you are not allowed to specify the DIFLABEL statement.

The following example creates an access descriptor and a view descriptor based on .DIF file data.

options linesize=80;
libname difdliba 'SAS-data-library';
libname diflibv 'SAS-data-library';

proc access dbms=dif;
/* create access descriptor */
   create difliba.custs.access;         
   path='c:\difiles\dbcusts.dif';
   diflabel;
   skiprows=2;
   assign=yes;
   rename customer = custnum;
   format firstorder date9.;
   list all;

/* create usacust view      */
   create diflibv.usacust.view;          
   select customer state zipcode name
          firstorder;
run;

SKIPROWS <=> number-of-rows-to-skip;
specifies the number of rows, beginning at the top of the DIF file, to ignore when reading data from the file. The default value for SKIPROWS is 0. The skipped (or ignored) rows often contain information such as column labels or names or underscores rather than input data.

If you specify the DIFLABEL statement, the default value of SKIPROWS automatically changes to 1. The SKIPROWS statement should always follow the PATH= statement and precede any editing statements when you are creating a descriptor. The first row of data after SKIPROWS is used to generate the SAS variable types and formats. If there are no data in the first row of a column after SKIPROWS, the data in the rest of the column are assumed to be character, even if the data in the next row are numeric.

By default, any data value in a column that does not match the type is treated as a missing value. However, if you set the DIFNUMS environment variable to YES in your SAS configuration file, any numeric data values in a character column are converted to the character representation of the number and are not treated as missing values. Add the following line to your SAS configuration file to set the DIFNUMS environment variable to YES:

-SET DIFNUMS YES

The default for the DIFNUMS environment variable is NO. Refer to the SAS documentation for your operating environment for more information about environment variables.

You can change the column type from the type determined by SAS/ACCESS software when you create an access descriptor.

TYPE <'>column-identifier-1 <'> <=> C | N < . . .column-identifier-n <=> C | N>;
changes the expected data types of SAS variables. SAS data sets have two data types: character (C) and numeric (N). Spreadsheet files have the same two data types: character (for labels and formula strings) and numeric (for numbers and formulas). Changing the default data type of a SAS variable in a descriptor file also changes its associated default format in the loaded file.

If you omit the TYPE statement, the database field types are generated from the PC file data types. You can change as many database field types as you want in one TYPE statement.


Chapter Contents

Previous

Next

Top of Page

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