Chapter Contents |
Previous |
Next |
PROC DBF |
Syntax |
PROC DBF options; |
filename myref '/my_dir/myfile.dbf'
).
If you specify a filename instead of a fileref, you can only specify the name itself (omitting the DBF extension) and the file must be in the current directory. For example, this PROC DBF statement creates the EMP.DBF file (uppercase) from the MYLIB.EMPLOYEE data set:
proc dbf db5=emp data=mylib.employee;You cannot specify
emp.dbf
or a full
pathname (
proc dbf db5='/my/unix_directory/emp.dbf'
) in the DBn= option.
The DBn option must correspond to the version
of dBASE with which the DBF file is compatible. You specify a DBF file with
the DBn option, where n is 2, 3, 4, or 5. You can
specify only one of these values. If you specify
DB4=myfile
, SAS looks for (and creates, depending on your options)
a file called
MYFILE.DBF
,
where the name is converted to uppercase.
If OUT= is omitted, SAS creates a temporary data set in the WORK library. (Under UNIX and OS/390, the temporary data set is named DATA1 [...DATAn]; under PCs, it is called _DATA_.) 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, but it is not permanently saved.
Details |
The DBF procedure converts dBASE files to SAS data sets that are compatible with the current release of the SAS System. This procedure can also be used to convert SAS data sets to DBF files.
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.
Future versions of dBASE files might not be compatible with the current version of the DBF procedure. SAS Institute cannot be responsible for upgrading PROC DBF to support new versions of dBASE with each new version of SAS software. To use the DBF procedure, you must have a SAS/ACCESS interface to PC File Formats license.
Converting DBF Fields to SAS Variables |
Character variables become SAS character variables. Any character variable of a length greater than 200 is truncated to 200. Logical fields become SAS character variables with a length of 1. Date fields become SAS date variables. When converting a DBF file to a SAS data set, fields whose data are stored in auxiliary DBF files (Memo and General fields) are ignored.
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 |
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 the character
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
from a SAS data set to a dBASE II file, SAS date variables become dBASE II
character fields in the form YYYMMDD.
Transferring Other Software Files to DBF Files |
Examples |
libname save '/my/unx_save_dir'; proc dbf db2=employee out=save.employee; run;
In this example, a SAS data set is converted to a dBASE 5 file. A FILENAME statement specifies a fileref that names the dBASE 5 file. You must specify the FILENAME statement before the PROC DBF statement.
libname mylib '/my/unix_directory'; filename employee '/sasdemo/employee.dbf'; proc dbf db5=employee data=mylib.employee; run;
In a Windows environment, this example would be:
libname mylib 'c:\my\directory'; filename employee 'c:\sasdemo\employee.dbf'; proc dbf db5=employee data=mylib.employee; run;
In an OS/390 environment, this example would be:
libname mylib 'sasdemo.employee.data'; filename dbfout 'sasdemo.newemp.dbf' recfm=n; proc dbf db5=dbfout data=mylib.employee; run;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.