Reading Free-Format Data | |
Mixing Input Styles![]() |
![]() |
Evaluating your raw data and choosing the most appropriate input style is a very important task. You have probably worked with three primary input styles for reading raw data. |
Reads | |
---|---|
Column | standard data values in fixed fields |
Formatted | nonstandard data values in fixed fields |
List | data values that are not arranged in fixed fields, but are separated by blanks or other delimiters |
With some file layouts, you may need to mix input styles
in the same INPUT statement in order to read the data correctly.
Look at the raw data file below and think about how to combine input styles to read these values. |
209-20-3721 07JAN78 41,983 SALES 2896
223-96-8933 03MAY86 27,356 EDUCATION 2344
232-18-3485 17AUG81 33,167 MARKETING 2674
251-25-9392 08SEP84 34,033 RESEARCH 2956
|
Field Description |
Starting Column |
Field Width |
Data Type | Input Style |
|
1 |
11 |
character | column |
Date of Hire |
13 |
7 |
date | formatted |
Annual Salary |
21 |
6 |
numeric | formatted |
Department | 28 |
5 to 9 |
character | list |
Phone Extension |
?? |
4 |
numeric | list |
The INPUT statement to read the data should look like this: |
data perm.mixed; infile rawdata; input SSN $ 1-11 @13 HireDate date7. |
When you submit the PRINT procedure, the output displays values for each variable. |
Obs | SSN |
HireDate | Salary | Department | Phone |
1 | 209-20-3721 | 6581 | 41983 | SALES |
2896 |
2 | 223-96-8933 | 9619 | 27356 | EDUCATION |
2344 |
3 | 7899 | 33167 | 2674 |
||
4 | 251-25-9392 | 9017 | 34033 | RESEARCH |
2956 |
![]() ![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.