notes5 - 1 1 Notes 5: Reading Raw Data Files and Instream...

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 5: Reading Raw Data Files and Instream Data Using List Input 2 List Input with the Default Delimiter s The data is not in fixed columns. s The fields are separated by spaces. s There is one nonstandard field. 50001 4feb1989 132 530 50002 11nov1989 152 540 50003 22oct1991 90 530 50004 4feb1993 172 550 50005 24jun1993 170 510 50006 20dec1994 180 520 3 List Input • Raw data with fields that are not in fixed columns is called free format . Use list input to read free-format data. • The list input style signals to the SAS System that fields are separated by delimiters. • SAS then reads from non-delimiter to delimiter instead of from a specific location on the raw data record. 4 Delimiters tab characters A space (blank) is the default delimiter. blanks commas Common delimiters are 5 List Input • General form of the INPUT statement for list input: • You must specify the variables in the order that they appear in the raw data file. • For standard data, specify a $ after the variable name if it is character. No symbol after the variable name indicates a numeric variable. INPUT var-1 $ var-2 . . . var-n ; INPUT var-1 $ var-2 . . . var-n ; 6 Informats • To read in nonstandard data, you must apply an informat. • General form of an informat: • Informats are instructions that specify how SAS reads raw data. < $ > INFORMAT-NAME<w> .< d > < $ > INFORMAT-NAME<w> .< d > 2 7 Specifying an Informat • To specify an informat for list input, use the colon (:) format modifier in the INPUT statement between the variable name and the informat. • General form of a format modifier in an INPUT statement: INPUT variable : informat ; INPUT variable : informat ; 8 Without the Colon • The colon signals that SAS should read from delimiter to delimiter. • If the colon is omitted, SAS reads the length of the informat , which may cause it to read past the end of the field. – No error message is printed. – You might see invalid data messages or unexpected data values. 9 Reading a Delimited Raw Data File • How does SAS determine the lengths of these variables? data airplanes; infile ' raw-data-file '; input ID $ InService : date9. PassCap CargoCap; run; 10 Lengths of Variables • When you use list input, the default length for character and numeric variables is eight bytes. • You can set the length of character variables with a LENGTH statement or with an informat. • General form of a LENGTH statement: LENGTH variable-name <$> length-specification ... ; LENGTH variable-name <$> length-specification ... ; 11 Setting the Length of a Variable data airplanes; length ID $ 5; infile ' raw-data-file '; input ID $ InService : date9. PassCap CargoCap; run; 12 ID $ 5 data airplanes; length ID $ 5; infile ' raw-data-file '; input ID $ InService : date9....
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

notes5 - 1 1 Notes 5: Reading Raw Data Files and Instream...

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