CH3 - STAT1303 Data Management 3. Reading Data into SAS 3...

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

View Full Document Right Arrow Icon
STAT1303 Data Management 3. Reading Data into SAS 3 Reading Data into SAS After the introduction of SAS, reading data into the SAS system can be in the SAS program directly. 3.1 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 a part of the data entry task. Basically, 3 styles of raw data input are available for the Data Step, namely, (1) LIST input, (2) COLUMN input and (3) FORMATTED input. For practical use, these 3 methods can be used with combination. Usually, raw data are arranged in one of the following 2 styles: Case 1. Data values come consecutively and are not aligned across lines. XXXXX YYYY ZZZZ UUUUUUUU XX YYYY ZZZZZ UU XXXXXXXX YY ZZZZZZ UUUU Case 2. Data values are aligned across lines. XXXXX YYYY ZZZZ UUUUUUUU XX YYYY ZZZZZ UU XXXXXXXX YY ZZZZZZ UUUU Alternatively, there are other forms of data input. For example, 1. Data may be entered into computer using another software, e.g. Excel, and Access and etc. . 2. SAS provides facilities to convert data from some common software packages into SAS data sets. driver and so on. HKU STAT1303 (2009-10, Semester 1) 3 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
STAT1303 Data Management 3. Reading Data into SAS 3.1.1 How Data Step works? Compile SAS statements (including synatx checking) Create 1. an input buffer, 2. a program data vector 3. descriptor information Begin with a DATA statement (counts iterations) Set variable values to missing in the program data vector. Data reading statement: is there a record to read? YES NO Read an in put record Execute additional executable statements Write an observation to the data set Return to the beginning of the DATA step. Close data set; goes on the next DATA or PROC step. Compile Phrase Execution Phrase HKU STAT1303 (2009-10, Semester 1) 3 2
Background image of page 2
STAT1303 Data Management 3. Reading Data into SAS 3.1.1.1 Steps in Data Step execution 1. When Data Step starts, an input bu/er and a program data vector are created. 2. The program loops through the following until no more input record can be read. (a) Sets variable values to missing in the program data vector. (b) Read an input record through the input bu/er and assign variable values to the program data vector. (c) Execute additional executable statements. (d) Write an observation to the SAS data set from the program data vector. 3.1.2 LIST input raw data. The separator is called a delimiter. Suppose the space character is the delimiter. XXXXX YYYY ZZZZ UUUUUUUU
Background image of page 3

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

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

Page1 / 10

CH3 - STAT1303 Data Management 3. Reading Data into SAS 3...

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

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