| The DBF and DIF Procedures |
| Restrictions: | The DIF procedure is available only under UNIX and Microsoft Windows operating environments. |
Syntax |
| PROC DIF options; |
specifies the fileref or filename of a DIF file.
If you specify a fileref, the FILENAME statement that you used to define it must specify the filename plus a .dif extension. For example, filename myref '/my_dir/myfile.dif' .
If you specify a filename instead of a fileref, you can specify only the name itself (omitting the .dif extension) and the file must be in the current directory. For example, this PROC DIF statement creates the Emp.dif file from the MyLib.Employee data set:
proc dif dif=emp data=mylib.employee;You cannot specify emp.dif or a full pathname (proc dif dif='/my/unix_directory/emp.dif' ).
names the input SAS data set. Use this option if you are creating a DIF file from a SAS data set. If you use this option, do not use the OUT= option. If you omit the DATA= option, SAS creates an output SAS data set from the DIF file.
names the SAS data set to hold the converted data. You use this option only if you omit the DATA= option and you are creating a SAS data set from a DIF file.
If OUT= is omitted, SAS creates a temporary data set in the Work library. (Under UNIX, the temporary data set is named Data1 [...Datan]. Under Microsoft Windows, it is called _DATA_. If OUT= is omitted or if you do not specify a two-level name in the OUT= option, the data set remains available during your current SAS session but is not permanently saved.
causes PROC DIF to write the names of the SAS variables as the first row of the DIF file and a row of blanks as the second row of the DIF file. The actual data portion of the DIF file begins in the third row. The LABELS option is allowed only when you are converting a SAS data set to a DIF file.
specifies a prefix to be used in constructing SAS variable names when you are converting a DIF file to a SAS data set. For example, if PREFIX=VAR, the new variable names are VAR1, VAR2, ... VARn. If you omit the PREFIX= option, PROC DIF assigns the names Col1, Col2, ... Coln.
specifies the number of rows, beginning at the top of the DIF file, to be ignored when converting a DIF file to a SAS data set. For example, the first row of your DIF file contains column headings and the second row of your DIF file is a blank row. The actual data in your DIF file begins in row 3. You should specify SKIP=2 so that PROC DIF ignores the nondata portion of your DIF file. You could also delete the first two rows of your DIF file before using PROC DIF.
| Details |
The DIF procedure converts data interchange format (DIF) files to SAS data sets that are compatible with the current release of SAS software, or it converts SAS data sets to DIF files.
PROC DIF produces one output file but no printed output. The output file contains the same information as the input file but in a different format.
Software Arts, Inc. developed the data interchange format to be used as a common language for data. Originally, DIF was made popular by products such as Lotus 1-2-3 and VisiCalc. Although DIF is not as popular today as it once was, it is still supported by many software products.
Note: Any DIF file that you plan to convert to a SAS data set should be in a tabular
format. All items in a given column should represent the same
type of data. If any rows in the DIF file contain inconsistent data--for
example, a row of underscores, dashes, or blanks--delete these rows before
converting the DIF file to a SAS data set. It is recommended that you make
a backup copy of your DIF table before you make these modifications. ![[cautionend]](../../../../common/62850/HTML/default/images/cautend.gif)
When you are converting data from a DIF file to a SAS data set, each row of the DIF file becomes an observation in the SAS data set. Conversely, when you are converting a SAS data set to a DIF file, each SAS observation becomes a row in the DIF file. To use the DIF procedure, you must have a SAS/ACCESS Interface to PC Files license.
| Converting DIF Variables to SAS Variables |
Character variables in a DIF file (sometimes referred to as string values) become SAS character variables of length 20. If a DIF character variable's value is longer than 20 characters, it is truncated to a length of 20 in the SAS output data set. The quotation marks that normally enclose character variable values in a DIF file are removed when the value is converted to a SAS character value.
Numeric variables, which can be represented in either integer or scientific notation in a DIF file, become SAS numeric variables when a DIF file is converted to a SAS data set.
| Transferring SAS Data Sets to and from Other Software Products Using DIF |
DIF files are not generally used as the native file format for a software product's data storage. Therefore, transferring data between SAS and another software product is a two-step process when using DIF files.
To send SAS data sets to another software product using DIF files, you must first run PROC DIF to convert your SAS data set to a DIF file. Use whatever facility is provided by the target software product to read the DIF file. For example, you use the Lotus 1-2-3 Translate Utility to translate a DIF file to a 1-2-3 worksheet file. (This facility might be provided by an import tool or from an Open window in that software product.) After the application reads the DIF file data, the data can be manipulated and saved in the application's native format.
To transfer data in the opposite direction -- from a software product to a SAS data set -- the process is reversed. First, export the data to a DIF file and then run PROC DIF to read the DIF file into a SAS data set.
| Missing Values |
The developers of the data interchange format (DIF) files suggest that you treat all numeric values that have a value indicator other than V as missing values. PROC DIF follows this convention. When a DIF file is converted to a SAS data set, any numeric value with a value indicator other than V becomes a SAS missing value.
When a SAS data set that has missing values for some numeric variables is converted to a DIF file, the following assignments are made in the DIF file for the variables with missing values:
the number field value contains a string of 16 blanks
| Examples |
In this example, a DIF file named Employee.dif is converted to a SAS data set. Because no FILENAME statement is specified, the last level of the filename is assumed to be .dif, and the file is assumed to be in your current directory and in uppercase.
LIBNAME save '/my/my_unx_dir'; proc dif dif=employee out=save.employee; run;
In this example, a SAS data set is converted to a DIF file. A FILENAME statement is used to specify a fileref that names the DIF file. You must specify the FILENAME statement before the PROC DIF statement.
filename employee 'c:\sasdemo\employee.dif'; proc dif dif=employee data=save.employee; run;
Here is the same example in a UNIX environment:
filename employee '/sasdemo/employee.dif'; proc dif dif=employee data=save.employee; run;
| See Also |
"Programmer's Guide to the DIF," Software Arts Technical Notes (SATN-18).
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.