SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Raw Data
Writing the DATA Step Program


Column Input

In this lesson, you'll be working with column input, the most common input style. Column input specifies actual column locations for values. However, column input is appropriate only in certain situations. When you use column input, your data must be

  • standard character or numeric values
  • in fixed fields.

Standard and Nonstandard Numeric Data

Standard numeric data values can only contain

  • numbers
  • decimal points
  • numbers in scientific, or E, notation (23E4)
  • minus signs.

Nonstandard numeric data include

  • values that contain special characters, such as percent signs (%), dollar signs ($), and commas (,)
  • date and time values
  • data in fraction, integer binary and real binary, and hexadecimal forms.

The external file referenced by the fileref Staff contains the personnel information for a technical writing department of a small computer manufacturer. The fields contain values for each employee's last name, first name, job title, and annual salary.


Raw Data File Staff

1---+----10---+----20---+---
EVANS   DONNY 112 29,996.63 
HELMS   LISA  105 18,567.23 
HIGGINS JOHN  111 25,309.00 
LARSON  AMY   113 32,696.78 
MOORE   MARY  112 28,945.89  


Notice that the values for Salary contain commas. So, the values for Salary are considered to be nonstandard numeric values.

Fixed Field Data

Raw data can be organized in several different ways.

This external file contains data that is free-format, meaning data that is not arranged in columns. Notice that the values for a particular field do not begin and end in the same columns. Column input can not be used to read data organized in this way.
1---+----10---+----20
BARNES NORTH 360.98
FARLSON WEST 243.94
LAWRENCE NORTH 195.04
NELSON EAST 169.30
STEWART SOUTH 238.45
TAYLOR WEST 318.87  

This external file contains data that is arranged in columns or fixed fields. You can specify a beginning and ending column for each field. Let's look at how column input can be used to read this data.
1---+----10---+----20
2810 61 MOD  F
2804 38 HIGH F 
2807 42 LOW  M 
2816 26 HIGH M
2833 32 MOD  F
2823 29 HIGH M 


 

back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement