Data Analysis

Submitted by: Submitted by

Views: 106

Words: 287

Pages: 2

Category: Business and Industry

Date Submitted: 09/29/2013 12:46 AM

Report This Essay

Sometimes you need to read a record, and hold that record in the input buffer while you test for a specified condition before a decision can be made about further processing. As an example, the ability to hold a record so that you can read from it again, if necessary, is useful when you need to test for a condition before SAS creates an observation from a data record. To do this, you can use the trailing at-sign (@).

For example, to create a SAS data set that is a subset of a larger group of records, you might need to test for a condition to decide if a particular record will be used to create an observation. The trailing at-sign placed before the semicolon at the end of an INPUT statement instructs SAS to hold the current data line in the input buffer. This makes the data line available for a subsequent INPUT statement. Otherwise, the next INPUT statement causes SAS to read a new record into the input buffer. You can set up the process to read each record twice by following these steps:

1 Use an INPUT statement to read a portion of the record.

2 Use a trailing @ at the end of the INPUT statement to hold the record in the input buffer for the execution of the next INPUT statement.

3 Use an IF statement on the portion that is read in to test for a condition.

4 If the condition is met, use another INPUT statement to read the remainder of the record to create an observation.

5 If the condition is not met, the record is released and control passes back to the top of the DATA step.