Reading Raw 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. |
Raw Data Files A raw data file is an external file whose records contain data values organized in fields. The raw data files in this lesson contain fixed fields.
Steps to Create a SAS Data Set
Referencing a SAS Data Library
Referencing a Raw Data File
Viewing Active Librefs and Filerefs
Writing the DATA step Program Next, you specify the raw data file by using the INFILE statement. The OBS= option in the INFILE statement enables you to process only through record n. You can also use the PAD option with the INFILE statement if the raw data file contains data lines of different lengths. This lesson teaches column input, the most common input style. Column input specifies actual column locations for data values. The INPUT statement describes the raw data to be read and placed into the SAS data set.
Submitting the Program After you submit the program, view the log to check the DATA step processing. You can then list the data set by using the PROC PRINT procedure. Once you've checked the log and verified your data, you can modify the DATA step to read the entire raw data file by removing the OBS= option from the INFILE statement. If you are working with a raw data file that contains invalid data, the DATA step continues to execute. Unlike syntax errors, invalid data errors do not cause the SAS System to stop processing a program. If you have a way to edit the invalid data, it's best to correct the problem and rerun the DATA step.
Subsetting Data |
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; |
INFILE file-specification <OBS=n>; |
RUN; |
PROC PRINT DATA=SAS-data set; |
RUN; |
The example shown below uses a column input style to read the first five
observations in the raw data file
C:\Clinic\Patients\admit.dat. The SAS data set named
Admittance will be stored in the SAS library
|
1---+----10---+----20 |
58MOD M |
29LOW F |
34LOW M |
41HIGHF |
30MOD F |
22HIGHM |
libname clinic 'c:\bethesda\patients\admit'; filename admit 'c:\clinic\patients\admit.dat'; data clinic.admittance; infile admit obs=5; input Age 1-2 Actlevel $ 3-6 Sex $ 7; run; proc print data=clinic.admittance; run; |
|
![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |