notes10 - 1 1 Notes 10: Multiple Records per Observation 2...

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 10: Multiple Records per Observation 2 Multiple Records Per Observation A raw data file has three records per employee. Record 1 contains the first and last names. Record 2 contains the city and state of residence. Record 3 contains the employees phone number. Farr, Sue Anaheim, CA 869-7008 Anderson, Kay B. Chicago, IL 483-3321 Tennenbaum, Mary Ann Jefferson, MO 589-9030 3 Desired Output The SAS data set should have one observation per employee. LName FName City State Phone Farr Sue Anaheim CA 869-7008 Anderson Kay B. Chicago IL 483-3321 Tennenbaum Mary Ann Jefferson MO 589-9030 4 The INPUT Statement The SAS System loads a new record into the input buffer when it encounters an INPUT statement. You can have multiple INPUT statements in one DATA step. Each INPUT statement ends with a semicolon. DATA SAS-data-set ; INPUT var-1 var-2 var-3 ; INPUT var-4 var-5 ; additional SAS statements DATA SAS-data-set ; INPUT var-1 var-2 var-3 ; INPUT var-4 var-5 ; additional SAS statements 5 data address; length LName FName $ 20 City $ 25 State $ 2 Phone $ 8; infile addresses.dat' dlm=','; input LName $ FName $; input City $ State $; input Phone $; run; Load Record Load Record Load Record Multiple INPUT Statements 6 Line Pointer Controls You can also use line pointer controls to control when SAS loads a new record. SAS loads the next record when it encounters a forward slash. DATA SAS-data-set ; INPUT var-1 var-2 var-3 / var-4 var-5 ; additional SAS statements DATA SAS-data-set ; INPUT var-1 var-2 var-3 / var-4 var-5 ; additional SAS statements 2 7 data address; length LName FName $ 20 City $ 25 State $ 2 Phone $ 8; infile 'addresses.dat ' dlm=','; input LName $ FName $ / City $ State $ / Phone $; run; Reading Multiple Records Per Observation Load Record Load Record Load Record 8 NOTE: 9 records were read from the infile 'addresses.dat'. The minimum record length was 8. The maximum record length was 20. NOTE: The data set WORK.ADDRESS has 3 observations and 5 variables. Reading Multiple Records Per Observation Partial Log 9 LName FName City State Phone Farr Sue Anaheim CA 869-7008 Anderson Kay B. Chicago IL 483-3321 Tennenbaum Mary Ann Jefferson MO 589-9030 Reading Multiple Records Per Observation proc print data=address noobs; run; PROC PRINT Output 10 Mixed Record Types Not all records have the same format. 101 USA 1-20-1999 3295.50 3034 EUR 30JAN1999 1876,30 101 USA 1-30-1999 2938.00 128 USA 2-5-1999 2908.74 1345 EUR 6FEB1999 3145,60 109 USA 3-17-1999 2789.10 11 Desired Output Sales Sale ID Location Date Amount 101 USA 14264 3295.50 3034 EUR 14274 1876.30 101 USA 14274 2938.00 128 USA 14280 2908.74 1345 EUR 14281 3145.60 109 USA 14320 2789.10 12 The INPUT Statement Use multiple INPUT statements....
View Full Document

Page1 / 11

notes10 - 1 1 Notes 10: Multiple Records per Observation 2...

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