notes4 - 1 1 Notes 4: Reading Raw Data Files Using Column...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 1 Notes 4: Reading Raw Data Files Using Column and Formatted Input 2 Reading Raw Data Files 1 1 2 1---5----0----5----0 43912/11/00LAX 20137 92112/11/00DFW 20131 11412/12/00LAX 15170 98212/12/00dfw 5 85 43912/13/00LAX 14196 98212/13/00DFW 15116 43112/14/00LaX 17166 98212/14/00DFW 7 88 11412/15/00LAX 187 98212/15/00DFW 14 31 Description Column Flight Number 1- 3 Date 4-11 Destination 12-14 First Class Passengers 15-17 Economy Passengers 18-20 Data for flights from New York to Dallas (DFW) and Los Angeles (LAX) is stored in a raw data file. Create a SAS data set from the raw data file dfwlax.dat. 3 data SAS-data-set-name ; infile ' raw-data-filename' ; input input-specifications; Creating a SAS Data Set 1 1 2 1---5----0----5----0 43912/11/00LAX 20137 92112/11/00DFW 20131 11412/12/00LAX 15170 Raw Data File DATA Step Flight Date Dest First Class Economy 439 12/11/00 LAX 20 137 921 12/11/00 DFW 20 131 114 12/12/00 LAX 15 170 SAS Data Set In order to create a SAS data set from a raw data file, you must 1. start a DATA step and name the SAS data set being created (DATA statement) 2. identify the location of the raw data file to read (INFILE statement) 3. describe how to read the data fields from the raw data file (INPUT statement). run; 4 Creating a SAS Data Set General form of the DATA statement: Example: This DATA statement creates a temporary SAS data set named dfwlax : Example: This DATA statement creates a permanent SAS data set named dfwlax : DATA libref.SAS-data-set(s) ; DATA libref.SAS-data-set(s) ; data work.dfwlax; libname st D:\Stat 440\'; data st .dfwlax; 5 Pointing to a Raw Data File General form of the INFILE statement: Examples: infile 'C:\data\dfwlax.dat '; INFILE filename < options >; INFILE filename < options >; 6 Reading Data Fields General form of the INPUT statement: input-specifications names the SAS variables identifies the variables as character or numeric specifies the locations of the fields in the raw data can be specified as column, formatted, list or named input. INPUT input-specifications; INPUT input-specifications; 2 7 Reading Data Using Column Input Column input is appropriate for reading data in fixed columns standard character and numeric data. General form of a column INPUT statement: Examples of standard numeric data: 15 -15 15.4 +1.23 1.23E3 -1.23E-3 INPUT variable <$> startcol-endcol . . . ; INPUT variable <$> startcol-endcol . . . ; 8 The Raw Data 1 1 2 1---5----0----5----0 43912/11/00LAX 20137 92112/11/00DFW 20131 11412/12/00LAX 15170 98212/12/00dfw 5 85 43912/13/00LAX 14196 98212/13/00DFW 15116 43112/14/00LaX 17166 98212/14/00DFW 7 88 11412/15/00LAX 187 98212/15/00DFW 14 31 Description Column Flight Number 1- 3 Date 4-11 Destination 12-14 First Class Passengers 15-17 Economy Passengers 18-20 9 Reading Data Using Column Input Raw Data File DATA Step SAS Data Set data SAS-data-set-name ; infile ' raw-data-filename '; input variable <$> startcol-endcol ... ;...
View Full Document

This note was uploaded on 10/31/2011 for the course STAT 440 taught by Professor Muyot,m during the Fall '08 term at University of Illinois, Urbana Champaign.

Page1 / 11

notes4 - 1 1 Notes 4: Reading Raw Data Files Using Column...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online