Previous Page | Next Page

Procedures under z/OS

DBF Procedure: z/OS



Converts a dBASE file to a SAS data set or a SAS data set to a dBASE file.
z/OS specifics: all

Syntax
Details
Converting DBF Fields to SAS Variables
Converting SAS Variables to DBF Fields
Transferring Other Software Files to DBF Files
Example 1: Converting a dBASE IV File to a SAS Data Set
Example 2: Converting a dBASE 5 file to a SAS Data Set

Syntax

PROC DBF options ;

The following options can be used in the PROC DBF statement:
DB2|DB3|DB4|DB5=fileref

specifies the fileref of a DBF file. The fileref can be allocated via a SAS FILENAME statement, a JCL DD statement (in batch mode), or a TSO ALLOC command (under TSO). For further information about fileref specification, see Ways of Allocating External Files. The DBF file can be stored as a sequential data set (such as sasdemo.emp.dbf), a partitioned z/OS data set member (such as sasdemo.dbf.pds(emp)), or a file in a hierarchical file system (such as /u/sasdemo/emp.dbf). For further information about file naming requirements, see Referring to External Files.

If the fileref is allocated with a FILENAME statement, the statement might specify RECFM=N to identify the DBF file as binary. This specification is optional.

The DBn option must correspond to the version of dBASE with which the DBF file is compatible. Specify a DBF file with the DBn option, where n is 2, 3, 4, or 5. You can specify only one of these values.

DATA=<libref.>member

names the input SAS data set, using 1-32 characters. Use this option if you are creating a DBF file from a SAS data set. If you use the DATA= option, do not use the OUT= option. If you omit the DATA= option, SAS creates an output SAS data set from the DBF file.

OUT=<libref.>member

names the SAS data set that is created to hold the converted data, using 1-32 characters. Use this option only if you do not specify the DATA= option. If OUT= is omitted, SAS creates a temporary data set in the WORK library. The name of the temporary data set is DATA1 [...DATAn]. If OUT= is omitted or if you do not specify a two-level name in the OUT= option, the SAS data set that is created by PROC DBF remains available during your current SAS session (under the temporary data set name), but it is not permanently saved.


Details

You can use PROC DBF in the z/OS environment if your site has a license for SAS/ACCESS for PC File Formats.

The DBF procedure converts files in DBF format to SAS data sets that are compatible with the current SAS release. You can also use PROC DBF to convert SAS data sets to files in DBF format.

Before you convert a DBF file to a SAS file, you must first upload your DBF file from the Windows or UNIX environments to the z/OS environment, using a mechanism such as FTP (file transfer protocol). If you are licensed for SAS/CONNECT, you can use PROC UPLOAD:

filename out1 'sasdemo.emp.dbf';
proc upload infile='c:\employee\emp.dbf'
   outfile=out1 binary;
run;

In the z/OS environment, sequential data sets are recommended for use with DBF, with the following attributes:

RECFM=FS

DSORG=PS

LRECL=6160

BLKSIZE=6160

The following example illustrates the specification of attributes for a sequential data set:
sasdemo.emp.dbf = (DSORG=PS,RECFM=FS,LRECL=6160,BLKSIZE=6160)

PROC DBF produces one output file but no printed output. The output file contains the same information as the input file but in a different format.

The DBF procedure works with DBF files created by all the current versions and releases of dBASE (II, III, III PLUS, IV, and 5.0) and with most DBF files that are created by other software products.


Converting DBF Fields to SAS Variables

When you convert a DBF file to a SAS data set, DBF numeric variables become SAS numeric variables. Similarly, DBF character variables become SAS character variables. Any DBF character variable of length greater than 254 is truncated to 254 in SAS. Logical fields become SAS character variables with a length of 1. Date fields become SAS date variables.

DBF fields whose data are stored in auxiliary files (Memo, General, binary, and OLE data types) are ignored in SAS.

If a DBF file has missing numeric or date fields, SAS fills those missing fields with a series of the digit 9 or with blanks, respectively.

When a dBASE II file is translated into a SAS data set, any colons in dBASE variable names are changed to underscores in SAS variable names. Conversely, when a SAS data set is translated into a dBASE file, any underscores in SAS variable names are changed to colons in dBASE field names.


Converting SAS Variables to DBF Fields

In DBF files, numeric variables are stored in character form. When converting from a SAS data set to a DBF file, SAS numeric variables become DBF numeric variables with a total length of 16. A SAS numeric variable with a decimal value must be stored in a decimal format in order to be converted to a DBF numeric field with a decimal value. In other words, unless you associate the SAS numeric variable with an appropriate format in a SAS FORMAT statement, the corresponding DBF field does not have any value to the right of the decimal point. You can associate a format with the variable in a SAS data set when you create the data set or by using the DATASETS procedure (see DATASETS Procedure: z/OS).

If the number of digits--including a possible decimal point--exceeds 16, a warning message is issued and the DBF numeric field is filled with a series of the digit 9. All SAS character variables become DBF fields of the same length. When converting from a SAS data set to a DBF file that is compatible with dBASE III or later, SAS date variables become DBF date fields. When converting to a dBASE II file, SAS date variables become dBASE II character fields in the form YYYYMMDD.


Transferring Other Software Files to DBF Files

You might find it helpful to save another software vendor's file to a DBF file and then convert that file into a SAS data set. For example, you could save an Excel XLS file in DBF format, upload the file, and use PROC DBF to convert that file into a SAS data set. Or you could do the reverse; use PROC DBF to convert a SAS data set into a DBF file and then load that file into an Excel spreadsheet.


Example 1: Converting a dBASE IV File to a SAS Data Set

In this example, a dBASE IV file named SASDEMO.EMPLOYEE.DBF is converted to a SAS data set. A FILENAME statement specifies a fileref that names the dBASE IV file. The FILENAME statement must appear before the PROC DBF statement, as shown:

libname save 'sasdemo.employee.data';
filename dbfin 'sasdemo.employee.dbf';
proc dbf db4=dbfin out=save.employee;
run;


Example 2: Converting a dBASE 5 file to a SAS Data Set

In this example, a dBASE 5 file is converted to a SAS data set.

libname demo 'sasdemo.employee.data';
filename dbfout 'sasdemo.newemp.dbf' recfm=n;
proc dbf db5=dbfout data=demo.employee;
run;

Previous Page | Next Page | Top of Page