BITSw.d Informat

Extracts bits.

Category: Numeric
Interaction: List input is incompatible with binary input when this informat is specified in an INFORMAT= statement or an ATTRIB= statement using the INFORMAT= argument. SAS issues a warning and uses formatted input to read the data.

Syntax

BITSw.d

Syntax Description

w

specifies the number of bits to read.

Default 1
Range 1–64

d

specifies the zero-based offset.

Range 0–63

Details

The BITSw.d informat extracts particular bits from an input stream and assigns the numeric equivalent of the extracted bit string to a variable. Together, the w and d values specify the location of the string that you want to read.
This informat is useful for extracting data from system records with many pieces of information packed into single bytes.

Example

input @1 value bits4.1;
Data Line
Result 1
----+----1----+
B
8
1The EBCDIC binary code for a capital B is 11000010, and the ASCII binary code is 01000010.
The input pointer moves to column 2 (d=1). Then the INPUT statement reads four bits (w=4), which is the bit string 1000, and stores the numeric value 8, which is equivalent to this binary combination.