U.S. Census Bureau

Delimiting records in ASCII text data files

Carriage Return/Line Feed Program - CRLF.EXE

Download DOS software version 1 (Enter parameters on command line) Note: doesn't run in Windows XP

Download DOS software version 2 (Prompts user to enter parameters)

Background

Tape File Math

This section applies to files with a fixed record length and without a header record (first record containing field names). The absence or existence of carriage return and/or line feed characters in the data file can be determined as follows.

    Go to a DOS prompt and run the DIR command and then perform the following three calculations.

Viewing the data file

with the following DOS command may also be useful. If there appear to be periodic breaks in the same place, do not use crlf.exe.

Type d:\filename.txt | more

where filename.txt is the data file name and d is the disc drive letter.

Usage

Examples

Reading data files into SAS and SPSS

The following instructions are intended to enable a data file with or without record separators to be read as-is 2. The instructions below are especially intended for SAS or SPSS users who do not have enough diskspace to store a copy of the CD-ROM file.

SAS Users

The Statistical Analysis System (SAS) can read files with unterminated records. Use the following technique:

  • data
  • infile 'input-file-name' lrecl=record-size recfm=F
  • input ...
  • run
SPSS Users

SPSS can read files with unterminated records. Use the following command

  • FILE HANDLE command
  • MODE subcommand
  • IMAGE option

Example:
file handle sipp /name='e:/sipp93w9.per' /mode=image lrecl=1460.

Please report your experience using this technique to techsupp@census.gov.

Footnotes

1. Another optional solution is available in this case. The data file can be compressed (if it isn't already) with PkZip or compatible program and then uncompressed with a program that will convert the line feed character to a carriage return and line feed character sequence. PKZIP for Windows version 4.00 (or a more recent version) can be used following the steps outlined below. This PKZIP shareware can be downloaded from pkware.com. After installing PKZIP, do the following:

2. Many Census Bureau data files, such as Current Population Survey (CPS), contain a line feed character only at the end of each record. One character needs to be added to the record length in the technical documentation whenever the record length is explicitly declared by use of the lrecl parameter (see Reading data files into SAS and SPSS above). Add two to the value of the lrecl parameter if a carriage return and line feed character sequence is present or leave out the lrecl parameter altogether.

A shift from record to record can occur when a carriage return and/or line feed character is present at the end of each record and the lrecl parameter is too small. Check for one or two character shifts in your datasets from record to record and adjust the recl parameter accordingly.


Source: U.S. Census Bureau, Administrative and Customer Services Division, Electronic Products Development Branch
Last Revised: June 13, 2005 at 10:29:17 AM