PROC DIF Statement Options

Convert a DIF file to SAS data set or a SAS data set to a DIF file.
Restriction: The DIF procedure is available only under UNIX and Microsoft Windows operating environments.


PROC DIF option(s);

Summary of Optional Arguments

PROC Statement
Statement Option

Optional Arguments

DIF = fileref | filename
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.
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. 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 pat name
PROC DIF dif='/my/unix_directory/emp.dif';
DATA= libref.member
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, the data set remains available during your current SAS session. The data set is not permanently saved.
specifies that PROC DIF writes the names of the SAS variables as the first row of the DIF file. It also writes 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.
Restriction:The LABELS option is allowed only when you are converting a SAS data set to a DIF file.
PREFIX= name
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, ... VAR n.
Default: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 non-data portion of your DIF file. You could also delete the first two rows of your DIF file before using PROC DIF.



The DIF procedure converts data interchange format (DIF) files to SAS data sets. The data sets are compatible with the current release of SAS software, or SAS data sets convert 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, it is still supported by many software products.
Note: Any DIF file that you plan to import 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 the DIF file contains inconsistent data, such as a row of underscores, hyphens, or blanks, delete these rows before converting the file. It is recommended that you make a backup copy of your DIF table before you make these modifications.
When you are converting a DIF file, each row of the file becomes an observation in the SAS data set. Conversely, when you are converting a SAS data set, 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 represented as integers or scientific notation in a DIF file, become SAS numeric variables when 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 transfer SAS data sets to another software product using DIF files, 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 from a software product to a SAS data set, reverse the process. Convert the data to a DIF file, run the DIF procedure to transfer 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 with a value indicator other than V as missing values. The DIF procedure follows this convention. When a DIF file is imported 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 with missing numeric values is converted to a DIF file, the following assignments are made in the DIF file for the variables with missing values:
  • the type indicator field value is set to 0
  • the number field value contains a string of 16 blanks
  • the value indicator is set to NA.


Example 1: Converting a DIF File to a SAS Data Set

A DIF file named Employee.dif is converted to a SAS data set. Because a FILENAME statement is not specified, the last level of the filename is assumed to be .dif. The file is assumed to be in your current directory, in uppercase.
LIBNAME save '/my/my_unx_dir';

Example 2: Converting a SAS Data Set to a DIF File

A SAS data set named EMP is converted to a DIF file. A FILENAME statement is used to specify a fileref that names the DIF file. Specify the FILENAME statement before the PROC DIF statement.
FILENAME employee 'c:\sasdemo\employee.dif';
PROC DIF DIF=employee DATA=save.employee;

Example 3: Convert a SAS Data Set to a DIF File in the UNIX Environment

This is basically the same codes as the previous example, coded for the UNIX environment. A SAS data set named EMP is converted to a DIF file. A FILENAME statement is used to specify a fileref that names the DIF file. Specify the FILENAME statement before the PROC DIF statement.
FILENAME emp '/sasdemo/emp_UNX.dif';
PROC DIF DIF=emp DATA=save.emp;