Values separated by something other than blanks
How do you read data with something other than blank delimiters? Consider the following code and data (from example 2).
DATA COMMAS; INFILE DATALINES DLM=','; INPUT ID HEIGHT WEIGHT GENDER $ AGE; DATALINES; 1,68,144,M,23 2,78,202,M,34 3,62,99,F,37 4,61,101,F,45 ; PROC PRINT DATA=COMMAS; TITLE 'Example 2.1'; RUN;
The things to notice in this example are:
The INPUT statement is identical to example 1. Recall that the INPUT statement tells SAS how to read data fields.
Infile statement INFILE fileref options; |
Describes the file that will be read by the next INPUT statement executed.
fileref reserved words are DATALINES and CARDS, refer to inline data.
options include:
DLM='characters' where the delimiter characters are enclosed in quotes. You can put a tab character between the quotes to read in tab-delimited data.
DSD specifies that two consecutive delimiters imply a missing value (for example: ,,) and a delimiter may be read as a data value if it is enclosed in quotes (for example: "Washington, George")