Phone2csv the two consecutive commas are not being

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: lts Adding the DSD option gives the expected results. PROC PRINT Output Adding the DSD option will correctly read the phone2.csv data file. Name proc print data=contacts noobs; run; 891(212) 891-3241 763(910) 763-5561 Mobile (701) (919) (212) (714) (910) 281281-8923 271-4592 271233233-5413 644644-9090 545545-3421 NOTE: 5 records were read from the infile 'phone2.csv'. The minimum record length was 31. The maximum record length was 44. NOTE: The data set WORK.CONTACTS has 5 observations and 3 variables. p107d05 70 Missing Values at the End of a Record (Self-Study) 7.06 Quiz (Self-Study) Open and submit p107a02. Examine the SAS log. How many input records were read and how many observations were created? The data values in phone.csv are separated by commas. Each record has a contact name, and then a phone number, and finally a mobile number. data contacts; length Name $ 20 Phone Mobile $ 14; infile 'phone.csv' dsd; input Name $ Phone $ Mobile $; run; The mobile number and phone.csv comma delimiter are missing 1 1 2 2 3 3 4 4 from some of the lines of data. 1---5----0----5----0----5----0----5----0----5 James Kvarniq,(704) 293-8126,(701) 281-8923 Sandrina Stephano,(919) 871-7830 Cornelia Krahl,(212) 891-3241,(212) 233-5413 Karen Ballinger,(714) 344-4321 Elke Wallstab,(910) 763-5561,(910) 545-3421 71 71 293(704) 293-8126 Partial SAS Log The DLM=',' option is no longer needed in the INFILE statement because the DSD option sets the default delimiter to a comma. 69 Phone James Kvarniq Sandrina Stephano Cornelia Krahl Karen Ballinger Elke Wallstab data contacts; length Name $ 20 Phone Mobile $ 14; infile 'phone2.csv' dsd; input Name $ Phone $ Mobile $; run; proc print data=contacts noobs; run; 72 12 Unexpected Results (Self-Study) Missing Values at the End of a Record (Self-Study) The missing mobile phone numbers caused unexpected results in the output. PROC PRINT Output Name Phone James Kvarniq Sandrina Stephano Karen Ballinger 293(704) 293-8126 871(919) 871-7830 (714) 344-4321 344- By default, when there is missing data at the end of a row, SAS does the following: loads the next record to finish the observation writes a note to the log Mobile 281(701) 281-8923 Cornelia Krahl Elke Wallstab Partial SAS Log NOTE: 5 records were read from the infile 'phone.csv'. The minimum record length was 31. The maximum record length was 44. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set WORK.CONTACTS has 3 observations and 3 variables. 73 74 The MISSOVER Option (Self-Study) 7.07 Quiz (Self-Study) The MISSOVER option prevents SAS from loading a new record when the end of the current record is reached. Open p107a03 and add the MISSOVER option to the INFILE statement. Submit the program and examine the SAS log. How many input records were read and how many observations were created? General form of an INFILE statement with a MISSOVER option: data contacts; length Name $ 20 Phone Mobile $ 14; infile 'phone.csv' dsd; input Name $ Phone $ Mobile $; run; INFILE 'raw-data-file-name' MISSOVER; If SAS reaches the end of the row without finding values for all fields, variables without values are set to missing. proc print data=contacts noobs; run; we can use DSD and MISSOVER together 75 76 Results (Self-Study) Chapter Review Adding the MISSOVER option gives the expected results. PROC PRINT Output 1. What statement identifies the physical filename of the raw data file to read? Name James Kvarniq Sandrina Stephano Cornelia Krahl Karen Ballinger Elke Wallstab Phone (704) (919) (212) (714) (910) 293293-8126 871-7830 871891891-3241 344344-4321 763763-5561 Mobile 2. What statement describes the arrangement of values in the raw data file? 281(701) 281-8923 233(212) 233-5413 545(910) 545-3421 3. What is the default delimiter when the DLM= option is used? Partial SAS Log NOTE: 5 records were read from the infile 'phone.csv'. The minimum record length was 31. The maximum record length was 44. NOTE: The data set WORK.CONTACTS has 5 observations and 3 variables. 77 4. What are the two phases of DATA step processing? 5. What is a program data vector (PDV)? 78 continued... 13 Chapter Review 6. Why would you use a LENGTH statement? 7. What is an instruction that SAS uses to read data values into a variable? 8. When would you use a : modifier? 79 14...
View Full Document

This document was uploaded on 02/25/2014 for the course STAT 410 at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online