Reading Free-Format Data | |
Lesson
Summary![]() ![]() |
![]() |
This page contains
|
I. Text Summary
To go to the page where a task, programming feature, or concept was presented, select a link. |
Free-Format Data External files can contain raw data that is free-format; that is, the data is not arranged in fixed fields. The fields can be separated by blanks, or some other delimiter, such as commas.
Using List Input When characters other than blanks are used to separate the data values, you can specify the field delimiter by using the DLM= option in the INFILE statement. In its simplest form, list input places several limitations on the types of data that can be read.
Reading Missing Values If your data contains missing values at the beginning or in the middle of a record, you must edit the file so that a period (.) holds the place of the missing value.
Changing the Length of Character Values Because variable attributes are defined when the variable is first encountered in the DATA step, the LENGTH statement precedes the INPUT statement and defines both the length and type of the variable. When you use the LENGTH statement, it is not necessary to specify the variable type again in the INPUT statement.
Modifying List Input
It's important to remember that informats work differently in modified list input than they do in formatted input.
Mixing Input Styles |
|
II. Syntax
To go to the page where a statement or option was presented, select a link. |
LIBNAME libref 'SAS-data-library'; |
FILENAME fileref 'filename'; |
DATA SAS-data-set; |
LENGTH variable $ length; |
INPUT variable <$> <&|:><informat>; |
RUN; |
PROC PRINT DATA=SAS-data-set; |
RUN; |
|
III. Sample Program
libname perm 'c:\records\data'; filename credit 'c:\records\credit.dat'; data perm.carduse; infile credit dlm='*' missover; length LastName $ 14; input lastname $ Gender $ Age CardType $ Total : comma.; run; proc print data=perm.carduse; run;
|
IV. Points to
Remember
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.