Chapter 3. Reading data

Chapter 3. Reading data - 1 Reading Data 2 ¡ Raw data...

Info iconThis preview shows pages 1–11. 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

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight 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 Reading Data 2 ¡ Raw data input ¢ How Data Step works? ¢ LIST input ¢ Column Input ¢ Formatted input ¢ Informats ¡ External data 3 Raw data input ¡ Converting non-SAS data (or raw data) into a SAS data set is a fundamental task in a data step. It is part of the data entry task. ¡ 3 basic styles of raw data input ¢ LIST input ¢ COLUMN input ¢ FORMATTED input ¢ Used individually or in combination ¡ Raw data can be part of a DATA step or can be located in an external file 4 Raw data ¡ Usually, raw data are arranged in one of the following 2 styles ¢ Data values come consecutively and are not aligned across lines XXXXX YYYY ZZZZ UUUUUUUU XX YYYY ZZZZZ UU XXXXXXXX YY ZZZZZZ UUUU ¢ Data values are aligned across lines XXXXX YYYY ZZZZ UUUUUUUU XX YYYY ZZZZZ UU XXXXXXXX YY ZZZZZZ UUUU 5 Other forms of data input ¡ Data may be entered into computer using another software, e.g. Excel, and Access, etc.. ¡ SAS provides facilities to convert data from some common software package into SAS data set ¡ SAS can directly access data file/system ¢ SAS/ACCESS ¢ Through ODBC driver ¢ … 6 How Data Step works? 7 Steps in a Data Step execution ¡ When Data Step starts, an input buffer and a program data vector are created ¡ The program loops through the following until no more input record can be read ¢ Sets variable values to missing in the program data vector ¢ Read an input record through the input buffer and assign variable values to the program data vector ¢ Execute additional executable statements ¢ Write an observation to the SAS data set from the program data vector 8 LIST input ¡ There must be a separator between data values in the first style of raw data. The separator is called a delimiter. ¢ Space is the delimiter XXXXX YYYY ZZZZ UUUUUUUU XX YYYY ZZZZZ UU XXXXXXXX YY ZZZZZZ UUUU ¡ When data values are separated by a delimiter character (most commonly used is a blank space), LIST input can be used ¡ LIST input means the input data are organized in a list form – variable 1 of observation 1 comes first, then variable 2 of observation 1, and so on, then variable 1 of observation 2, and so on; with each field separated by a delimiter 9 Example ¡ LIST input * Example 3.1 - LIST input; data rat; /* create SAS data set 'rat' */ input litter $ weighta weightb weighti weightj; cards; A 61.5 55 52.5 42 B 60.3 50.8 56.5 51.3 I 37 56.3 39.7 50 J 59 59.5 45.2 44.8 ; run; 10 ¡ The INPUT statement reads data into variables specified in the statement, in the exact order of the variables appeared in the statement ¡ In the INPUT statement, a ‘$’ is placed after the variable name LITTER. This tells SAS to make LITTER a character variable (of length 8, the default length) ¡ The INPUT statement has no other special characters,...
View Full Document

This note was uploaded on 02/09/2012 for the course STAT 1301 taught by Professor Smslee during the Spring '08 term at HKU.

Page1 / 29

Chapter 3. Reading data - 1 Reading Data 2 ¡ Raw data...

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

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