Study guide

2.5 Raw Data Ingestion with INFILE and INPUT Statements

SAS Certified Specialist: Base Programming Using SAS 9.4 A00-231

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: SAS Base Programming Exam Overview

1.1 A00-231 Exam Format, Scoring & Test-Day Logistics 1.2 Official Content Areas, Weights & Study Plan

2 Chapter 2: Accessing & Creating SAS Data Structures

2.1 SAS Environment, Syntax Rules, & Data Step Basics 2.2 SAS Data Libraries & the LIBNAME Statement 2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS 2.4 Importing Delimited & Excel Data with PROC IMPORT 2.5 Raw Data Ingestion with INFILE and INPUT Statements

3 Chapter 3: Managing & Combining SAS Data Sets

3.1 Reading SAS Data Sets with the SET Statement 3.2 Combining Data Sets: Concatenating & Interleaving 3.3 Match-Merging with BY Statements & FIRST./LAST. Processing 3.4 Controlling Data Output & Variable Selection (KEEP, DROP, RENAME, OBS=)

4 Chapter 4: Data Transformation & Conditional Logic

4.1 Creating & Modifying Variables with Assignment Statements 4.2 Modifying Variable Attributes with LENGTH, LABEL, FORMAT & RENAME= 4.3 Conditional Processing: IF-THEN/ELSE Statements & WHERE Subsetting 4.4 Accumulating Totals & Subtotals (RETAIN & Sum Statement) 4.5 Processing Data Iteratively with DO Loops

5 Chapter 5: SAS Functions & Data Type Conversions

5.1 Character Functions for String Manipulation 5.2 Numeric & Mathematical Functions 5.3 Working with SAS Dates, Times, & Intervals 5.4 Reading & Displaying Dates with Informats and Formats 5.5 Explicit & Implicit Data Type Conversions (INPUT & PUT)

6 Chapter 6: Restructuring Data & Program Maintenance

6.1 SAS Array Processing for Multi-Variable Transformations 6.2 Sorting Data Sets with PROC SORT 6.3 Restructuring Data Sets with PROC TRANSPOSE 6.4 Creating & Applying Custom Formats with PROC FORMAT 6.5 Simplifying Programs with Macro Variables (%LET)

7 Chapter 7: Error Handling & Debugging SAS Programs

7.1 SAS Log Analysis & Diagnostic Messages 7.2 Syntax vs. Logic Errors & Phasing 7.3 Debugging Techniques with _ERROR_, _N_, & PUT Statements 7.4 Identifying Logic Errors with the PUTLOG Statement 7.5 Handling Missing Values & Preventing Calculation Propagations

8 Chapter 8: Summary & Detail Data Reporting

8.1 Detail Reporting with PROC PRINT 8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY 8.3 Frequency & Categorical Analysis with PROC FREQ 8.4 Screening Extreme & Missing Values with PROC UNIVARIATE 8.5 Custom Tabular Reports with PROC REPORT & PROC TABULATE

9 Chapter 9: ODS Output Delivery & Data Export

9.1 Output Delivery System (ODS) Architecture Basics 9.2 Generating PDF, HTML, & RTF Output Destinations 9.3 Exporting Reports to Excel with ODS EXCEL & XLSX 9.4 Generating CSV, PowerPoint & Other ODS Destinations 9.5 Customizing ODS Titles, Footnotes, & Global Options 9.6 Exporting SAS Data Sets with PROC EXPORT & the XLSX Engine

2.5 Raw Data Ingestion with INFILE and INPUT Statements

Key Takeaways Explain This Topic AI

The INFILE statement identifies an external raw data file to be read within a DATA step, supporting options like DLM=, DSD, MISSOVER, TRUNCOVER, FIRSTOBS=, and OBS=.

The DSD (Delimiter-Sensitive Data) option treats consecutive delimiters as missing values, removes surrounding quotation marks from text, and sets the default delimiter to a comma.

MISSOVER prevents SAS from moving to the next line when a raw record ends prematurely, filling remaining INPUT variables with missing values.

TRUNCOVER forces SAS to read partial field values at the end of a line up to the line boundary without jumping to the next line.

The trailing single @ holds an input record for further processing within the current iteration, while the trailing double @@ holds a record across multiple DATA step iterations.

Last updated: August 2026

2.5 Raw Data Ingestion with INFILE and INPUT Statements

While PROC IMPORT provides quick automatic file ingestion, SAS Base programmers must master the INFILE and INPUT statements inside the DATA step for complete control over raw data parsing, complex informats, line-hold specifiers, and custom record structures.

1. The INFILE Statement & Essential Options

The INFILE statement specifies the external raw data file to be read by the INPUT statement in a DATA step. data work.raw_ingest;

  • infile "C:\\Data\\raw_payroll.txt" dlm=',' dsd missover firstobs=2 obs=100;
  • input employee_id : $8. hire_date : mmddyy10. salary : dollar10.2;
  • run;
  • Key INFILE Statement Options

Option Description & Exam Application

DLM='char' Defines the field delimiter (e.g., dlm=',' or dlm='09'x for tabs).

DSD Delimiter-Sensitive Data . Performs three critical tasks:; 1. Treats two consecutive delimiters as a missing value.; 2. Strips surrounding quotes from character values.; 3. Sets the default delimiter to a comma.

FIRSTOBS=n Specifies the line number of the first raw record to read (e.g., FIRSTOBS=2 skips header rows).

OBS=n Specifies the last line number of the raw record to read.

MISSOVER Prevents SAS from advancing to the next raw line if a record ends before all variables in the INPUT statement receive values; missing values ( . or blank) are assigned instead.

TRUNCOVER Reads short or partial field values up to the end of the line without jumping to the next line or padding with blanks. Needed when using column/formatted input on variable-length lines.

2. Line Boundary Handling: FLOWOVER vs. MISSOVER vs. TRUNCOVER

Understanding how SAS handles short records (records with fewer fields than variables in the INPUT statement) is critical for the exam:

FLOWOVER (the default) : If an INPUT statement reaches the end of a raw record before populating all variables, SAS automatically flows over to the next raw data line to read values for the remaining variables, consuming multiple physical lines per observation. The option is spelled FLOWOVER , not FLOW , and you rarely code it explicitly because it is already in effect.

MISSOVER : If an INPUT statement reaches the end of a raw record, SAS stops reading that record and sets all remaining unread variables to missing.

TRUNCOVER : Essential for formatted/column input. If a raw field is shorter than the informat width or truncated by the end of the line, TRUNCOVER reads whatever characters exist up to the line boundary into the PDV, rather than setting the variable to missing or jumping to the next record. /* Correct handling of short variable-length records */

  • data work.phone_directory;
  • infile "C:\\Data\\contacts.txt" missover;
  • input id $ name $ phone $ email $;
  • run;
  • 3. INPUT Statement Styles

SAS supports four distinct styles of input in the INPUT statement:

1. List Input

Variables are separated by spaces or delimiters. Values are read sequentially. input emp_id $ age department $ salary;

2. Column Input

Field locations are explicitly specified by column start and end positions. Spaces do not act as delimiters, allowing embedded blanks in string values. input name $ 1-20 title $ 21-35 age 36-37;

3. Formatted Input

Combines pointer controls ( @n , +n ) with SAS informats (instructions on how to read raw data formats into standard numeric or character values). input @1 emp_id $5. @7 hire_date mmddyy10. @18 salary dollar10.2;

4. Modified List Input

Uses informat modifiers ( : or ~ ) alongside standard list input:

: Modifier: Instructs SAS to read past the raw data value until it encounters a delimiter, applying the specified informat width without being constrained by fixed column boundaries.

~ Modifier: Preserves quotes in string values when used with DSD . /* Colon modifier allows reading formatted dates of varying field lengths */

  • input name : $20. start_date : date9. annual_pay : comma12.2;
  • 4. Pointer Controls & Line-Hold Specifiers ( @ and @@ )

Pointer controls direct SAS where to read in the input buffer:

@n : Absolute column pointer (moves pointer directly to column n ).

+n : Relative column pointer (moves pointer forward n columns).

/ : Line pointer control (advances pointer to column 1 of the next raw line).

  • Trailing Line-Hold Specifiers +-------------------------------------------------------------------------+
  • | TRAILING LINE-HOLD SPECIFIERS |
  • +-------------------------------------------------------------------------+
  • | Single Trailing @ | Holds line in buffer for current DATA step iter. |
  • | Double Trailing @@ | Holds line in buffer across multiple iterations. |
  • +-------------------------------------------------------------------------+
  • Single Trailing @

Holds a raw record in the input buffer so that subsequent INPUT statements within the same iteration of the DATA step can execute conditional logic before reading the rest of the record. data work.managers;

  • infile "C:\\Data\\staff.txt";
  • input type $ 1-1 @; /* Read type, hold record in buffer */
  • if type = 'M' then do;
  • input id $ 3-6 name $ 8-25 bonus dollar8.2;
  • output;
  • end;
  • run;
  • Double Trailing @@

Holds a raw record in the input buffer across multiple iterations of the DATA step. Used when a single line of raw data contains multiple observations. /* Single line contains 3 observations: 101 25 102 30 103 28 */

  • data work.patient_ages;
  • infile datalines;
  • input patient_id age @@; /* Holds line across iterations until empty */
  • datalines;
  • 101 25 102 30 103 28
  • 104 42 105 39
  • ;
  • run;