Chapter Contents

Previous

Next
PROC DIF

PROC DIF



converts a DIF file to SAS data set or a SAS data set to a DIF file


Syntax
PROC DIF Options
Details
Converting DIF Variables to SAS Variables
Transferring SAS Data Sets to and from Other Software Products Using DIF
Missing Values
Examples
Example 1: Converting a DIF File to a SAS Data Set
Example 2: Converting a SAS Data Set to a DIF File
See Also

Syntax

PROC DIF options;

PROC DIF Options

DIF=fileref | filename
specifies the fileref or filename of a DIF file. When you use the FILENAME statement to assign the fileref, the statement must specify the filename plus a .DIF extension (that is, filename myref '/my_dir/myfile.dif').

If you specify a filename instead of a fileref, you can only specify 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') in the DIF option.

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, the SAS System creates an output SAS data set from the DIF file.

OUT=<libref.>member
names the SAS data set to hold the converted data. Use this option only if you omit the DATA= option.

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 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 created by PROC DIF remains available during your current SAS session but is not permanently saved.

LABELS
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 converting a SAS data set to a DIF file.

PREFIX=name
specifies a prefix to be used in constructing SAS variable names when 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 to the variables in the output SAS data set.

SKIP=n
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, suppose 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 begin in row 3. You should specify SKIP=2 so that PROC DIF ignores the nondata portion of your DIF file. Alternatively, you could 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. This procedure can also be used to convert 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 form. 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]

When converting 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 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 File Formats 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 a File --> Open dialog box 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--for example, 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) 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:


Examples

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

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;

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

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;

Or, in a UNIX environment, this example would be:

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).


Chapter Contents

Previous

Next

Top of Page

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