lecture_03 - READING DATA INTO SAS Three general scenarios...

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

View Full Document Right Arrow Icon
Three general scenarios for reading data into SAS: Reading raw data using INPUT and DATALINES statements (we started to learn this last week and will continue to focus on this topic this week ) Reading an external datafile (non-SAS) using INPUT and INFILE statements (we will learn this this week) Reading an existing SAS dataset (easiest to do). (also this week, but in more detail later) READING DATA INTO SAS
Background image of page 1

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

View Full DocumentRight Arrow Icon
List Input : Data values must be separated by a delimiter (usually a blank space) Column Input : Data values are laid out in distinct columns Formatted Input : Enables you to supply special instructions for handling special data values (dates, times, numeric with commas, etc.) Mixed Input : Any combination of the above (BUT be careful – you might not get what you want !) STYLES OF INPUTTING DATA
Background image of page 2
LIST INPUT Use List input only if each field is separated by at least one delimiter (blank space) Variable names must be specified in the same order on the INPUT statement as they appear in the raw data records. Represent missing values by a placeholder (period) Character values cannot contain embedded blanks Default length of a character variable is eight bytes. SAS truncates a longer value when it writes the value to the PDV
Background image of page 3

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

View Full DocumentRight Arrow Icon
EXAMPLE: LIST INPUT DATA EXAMPLE; I NPUT NAME $ SEX $ AGE HEI GHT WEI GHT; BMI = ( WEI GHT* . 045) / ( ( HEI GHT* . 0254) * * 2) ; DATALI NES; - - - - +- - - - 1- - - - +- - - - 2- - - - STEVE M 41 74 170 ROCKY M 42 68 166 KURT M 39 72 167 DEBORAH F 30 66 124 JACQUELI NE F 33 . 115 ; You may find it useful to place a semi-input buffer after the DATALINES statement. (BUT delete before submitting program or you’ll get an ‘Invalid Data’ ERROR!!!) Note placeholder for the missing value
Background image of page 4
COLUMN INPUT Character variables can be up to 32,767 characters in length (not limited to default of 8 as in list input) Do not have to use a placeholder for missing values Character variables can contain embedded blanks Enables you to skip some data fields when reading records of raw data Enables you to read the data fields in any order Enables you to re-read fields or parts of fields
Background image of page 5

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

View Full DocumentRight Arrow Icon
DATA EXAMPLE; I NPUT NAME $ 1- 10 HEI GHT 17- 18 WEI GHT 20- 22 SEX $ 12 AGE 14- 15; BMI = ( WEI GHT* . 045) / ( ( HEI GHT* . 0254) * * 2) ; DATALI NES; - - - - +- - - - 1- - - - +- - - - 2- - - - +- - - - 3- - - - +- - - - 4- - - - +- - STEVE FORD M 41 74 170 ROCKY B M 42 68 166 KURT M 39 72 167 DEBORAH F 30 66 124 JACQUELI NE F 33 115 ; Note that we can now read in ‘Steve Ford’ and ‘Rocky B’ instead of ‘Steve’ and ‘Rocky’. We can also read the fields in
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

lecture_03 - READING DATA INTO SAS Three general scenarios...

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

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