Create an external format file that specifies the column metadata for the external
data file. In SAS Data Integration Studio, run the fixed-width external file wizard
and specify both the data file and the format file. The wizard uses the format file
to
register the column metadata for the data file. This reduces the need to manually specify
column metadata for the data file.
An external format file
describes the structure of the columns in an external data file. The
format file must be a well-formed file that the SAS INFILE statement
can read.
For example, the following
portion of a format file for a fixed-width data file contains census
data. The format file is in comma-separated-values (CSV) format.
Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat
RECTYPE,C,1,1,y,Record Type,$char.,$char.
SERIALNO,C,2,8,y,Serial #: Housing Unit ID,$char.,$char.
SAMPLE,C,9,9,y,Sample Identifier,,
DIVISION,C,10,10,y,Division code,,
STATE,C,11,12,y,State Code,,
PUMA,C,13,17,y,Public Use Microdata Area (State Dpndnt),,
AREATYPE,C,18,19,y,Area Type Rev. for PUMS Equavalency fl,,
MSAPMSA,C,20,23,y,MSA/PMSA,,
PSA,C,24,26,y,PLANNING SRVC AREA (ELDERLY SAMPLE ONLY),,
SUBSAMPL,C,27,28,y,SUBSAMPLE NUMBER (USE TO PULL EXTRACTS),,
HOUSWGT,N,29,32,y,Housing Weight,,
PERSONS,N,33,34,y,Number of person records this house,,
...
The values in the first
row are SAS column attributes. The values of subsequent rows specify
metadata for the columns in the external file, in this case a fixed-width
file that contains census data. Here is a description of the SAS column
attributes in the first row.
Name
A logical identifier
for the object, in this case a column name, such as RECTYPE and SERIALNO.
SASColumnType
This represents the
SAS type (character or numeric) for this column. The value can be
either 'C' or 'N'.
BeginPosition
The position within
a record where the column begins. This is used for external tables
and record-oriented tables.
EndPosition
The position within
the record where the column ends. This is used for external tables
and record-oriented tables.
ReadFlag
Indicates whether to
read the column. If set to N, the column is ignored when the data
is read in.
Desc
Brief description of
the object, in this case a column.
For a full description
of SAS column attributes, see the topics for the Column type and the
Logical Column type in the SAS Metadata Model: Reference.
The version of this book for SAS 9.3 applies to both SAS 9.3 releases
and SAS 9.4 releases. This book can be accessed from the “Documentation
by Title” section of the SAS Product Documentation page: http://support.sas.com/documentation/.
Note: If your external format file
does not specify SAS informats for all column variables, you need
to specify these manually in SAS Data Integration Studio. If appropriate
informats are not provided for all columns, then incorrect results
can be encountered when the external file is used in a job or when
its data is viewed.