Converts ASCII character data to native format
Category: Character
$ASCII w .
w
specifies the width of the input field.
Default: 1 if the length of the variable is undefined ; otherwise , the length of the variable
Range: 1 “32767
If ASCII is the native format, no conversion occurs.
On an IBM mainframe system, $ASCII w . converts ASCII data to EBCDIC.
On all other systems, $ASCII w . behaves like the $CHAR w . informat except that the default length is different.
input @1 name $ascii3.;
When the Data Line = | The Result [*] is | |
---|---|---|
----+----1 | EBCDIC | ASCII |
abc | 818283 | 616263 |
ABC | C1C2C3 | 414243 |
(); | 4D5D5E | 28293B |
[*] The results are hexadecimal representations of codes for characters . Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one character value. |
Converts binary data to character data
Category: Character
$BINARY w.
w
specifies the width of the input field. Because eight bits of binary information represent one character, every eight characters of input that $BINARY w . reads becomes one character value stored in a variable.
If w < 8, $BINARY w . reads the data as w characters followed by 0s. Thus, $BINARY4. reads the characters 0101 as 01010000, which converts to an EBCDIC & or an ASCII P . If w > 8 but is not a multiple of 8, $BINARY w . reads up to the largest multiple of 8 that is less than w before converting the data.
Default: 8
Range: 1 “32767
The $BINARY w . informat does not interpret actual binary data, but it converts a string of characters that contains only 0s or 1s as though it is actual binary information. Therefore, use only the character digits 1 and 0 in the input, with no embedded blanks. $BINARY w . ignores leading and trailing blanks.
To read representations of binary codes for unprintable characters, enter an ASCII or EBCDIC equivalent for a particular character as a string of 0s and 1s. The $BINARY w . informat converts the string to its equivalent character value.
The BINARY w . informat reads eight characters of input that contain only 0s or 1s as a binary representation of one byte of numeric data.
The $HEX w . informat reads hexadecimal digits that represent the ASCII or EBCDIC equivalent of character data.
input @1 name $binary16.;
When the Data Line = | The Result is | |
---|---|---|
----+----1----+----2 | ASCII | EBCDIC |
0100110001001101 | LM | < ( |
Reads standard character data from column-binary files
Category: Column Binary
$CB w.
w
specifies the width of the input field.
Default: none
Range: 1 “32767
The $CB w . informat reads standard character data from column-binary files, with each card column represented in 2 bytes, and it translates the data into standard character codes. If the combinations are invalid punch codes, SAS returns blanks and sets the automatic variable _ERROR_ to 1.
input @1 name $cb2.;
When the Data Line [*] = | The Result is | |
---|---|---|
----+----1 | EBCDIC | ASCII |
200A | + | N |
[*] The data line is a hexadecimal representation of the column binary. The punch card column for the example data has row 12, row 6, and row 8 punched. The binary representation is 0010 0000 0000 1010. |
Informats:
CB w . d Informat on page 974
PUNCH. d Informat on page 1010
ROW w . d Informat on page 1016
See the discussion on reading column-binary data in SAS Language Reference: Concepts .
Reads character data with blanks
Category: Character
$CHAR w.
w
specifies the width of the input field.
Default: 8 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
The $CHAR w . informat does not trim leading and trailing blanks or convert a single period in the input data field to a blank before storing values. If you use $CHAR w . in an INFORMAT or ATTRIB statement within a DATA step to read list input, then by default SAS interprets any blank embedded within data as a field delimiter , including leading blanks.
The $CHAR w . informat is almost identical to the $ w. informat. However $CHAR w . does not trim leading blanks or convert a single period in the input data field to a blank, while the $ w . informat does.
Use the table below to compare the SAS informat $CHAR8. with notation in other programming languages:
Language | Character Notation |
---|---|
SAS | $CHAR8. |
IBM 370 assembler | CL8 |
C | char [8] |
COBOL | PIC x(8) |
FORTRAN | A8 |
PL/I | CHAR(8) |
input @1 name $char5.;
When the Data Line = | The Result [*] is |
---|---|
----+----1 | |
XYZ XYZ . X YZ | XYZ## #XYZ# ##.## #X#YZ |
[*] The character # represents a blank space. |
Converts binary 0s to blanks
Category: Character
$CHARZB w.
w
specifies the width of the input field.
Default: 1 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
The $CHARZB w . informat does not trim leading and trailing blanks in character data before it stores values.
The $CHARZB w . informat is identical to the $CHAR w . informat except that $CHARZB w . converts any byte that contains a binary 0 to a blank character.
input @1 name $charzb5.;
When the Data Line [*] = | The Result is | |
---|---|---|
EBCDIC | ASCII | |
E7E8E90000 | 58595A0000 | XYZ## |
00E7E8E900 | 0058595A00 | #XYZ# |
00E700E8E9 | 005800595A | #X#YZ |
[*] The data lines are hexadecimal representations of codes for characters. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one character. ** The character # represents a blank space. |
Reads a character string that is encoded in Hebrew DOS (cp862) and then converts the character string to Windows (cp1255) encoding
Category: Hebrew text handling
Alignment: left
See: The $CPTDW informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in Windows (cp1255) and then converts the character string to Hebrew DOS (cp862) encoding
Category: Hebrew text handling
Alignment: left
See: The $CPTWD informat in SAS National Language Support (NLS): User s Guide
Converts EBCDIC character data to native format
Category: Character
$EBCDIC w.
w
specifies the width of the input field.
Default: 1 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
If EBCDIC is the native format, no conversion occurs.
On an IBM mainframe system, $EBCDIC w . behaves like the $CHAR w . informat.
On all other systems, $EBCDIC w . converts EBCDIC data to ASCII.
input @1 name $ebcdic3.
When the Data Line = | The Result [*] is | |
---|---|---|
----+----1 | ASCII | EBCDIC |
qrs | 717273 | |
9899A2 | ||
QRS | 515253 | D8D9E2 |
+; > | 2B3B3E | 4E5E6E |
[*] The results are hexadecimal representations of codes for characters. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one character value. |
Converts hexadecimal data to character data
Category: Character
See: $HEX w . Informat in the documentation for your operating environment.
$HEX w.
w
specifies the number of digits of hexadecimal data.
If w =1, $HEX w . pads a trailing hexadecimal 0. If w is an odd number that is greater than 1, then $HEX w . reads w “1 hexadecimal characters.
Default: 2
Range: 1 “32767
The $HEX w . informat converts every two digits of hexadecimal data into one byte of character data. Use $HEX w . to encode hexadecimal values into a character variable when your input method is limited to printable characters.
The HEX w . informat reads two digits of hexadecimal data at a time and converts them into one byte of numeric data.
input @1 name $hex4.;
When the data line = | The result is | |
---|---|---|
----+----1 | ASCII | EBCDIC |
6C6C | ll | %% |
Removes shift code data from DBCS data
Category: DBCS
See: The $KANJI informat in SAS National Language Support (NLS): User s Guide
Adds shift code data to DBCS data
Category: DBCS
See: The $KANJIX informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in left-to-right logical order and then converts the character string to visual order
Category: BIDI text handling
Alignment: left
See: The $LOGVS informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in right-to-left logical order and then converts the character string to visual order
Category: BIDI text handling
Alignment: left
See: The $LOGVSR informat in SAS National Language Support (NLS): User s Guide
Converts octal data to character data
Category: Character
$OCTAL w.
w
specifies the width of the input field in bits. Because one digit of octal data represents three bits of binary information, increment the value of w by three for every column of octal data that $OCTAL w . will read.
Default: 3
Range: 1 “32767
Eight bits of binary data represent the code for one digit of character data. Therefore, you need at least three digits of octal data to represent one digit of character data, which includes an extra bit. $OCTAL w . treats every three digits of octal data as one digit of character data, ignoring the extra bit.
Use $OCTAL w . to read octal representations of binary codes for unprintable characters. Enter an ASCII or EBCDIC equivalent for a particular character in octal notation. Then use $OCTAL w . to convert it to its equivalent character value.
Use only the digits 0 through 7 in the input, with no embedded blanks. $OCTAL w . ignores leading and trailing blanks.
The OCTAL w . informat reads octal data and converts them into the numeric equivalents.
input @1 name $octal9.;
When the Data Line = | The Result is | |
---|---|---|
----+----1 | EBCDIC | ASCII |
114 | < | L |
Converts packed hexadecimal data to character data
Category: Character
$PHEX w.
w
specifies the number of bytes in the input.
When you use $PHEX w . to read packed hexadecimal data, the length of the variable is the number of bytes that are required to store the resulting character value, not w . In general, a character variable whose length is implicitly defined with $PHEX w . has a length of 2 w “1.
Default: 2
Range: 1 “32767
Packed hexadecimal data are like packed decimal data, except that all hexadecimal digits are valid. In packed hexadecimal data, the value of the low-order nibble has no meaning. In packed decimal data, the value of the low-order nibble indicates the sign of the numeric value that the data represent. The $PHEX w . informat returns a character value and treats the value of the sign nibble as if it were X F , regardless of its actual value.
The PD w . d . informat reads packed decimal data and converts them to numeric data.
input @1 devaddr $phex2.;
When the Data Line [*] = | The Result is |
---|---|
0001111000001111 | 1E0 |
[*] The data line represents two bytes of actual binary data, with each half byte corresponding to a single hexadecimal digit. The equivalent hexadecimal representation for the data line is 1E0F. |
Removes matching quotation marks from character data
Category: Character
$QUOTE w.
w
specifies the width of the input field.
Default: 8 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
input @1 name $quote7.;
When the Data Line = | The Result is |
---|---|
----+----1 | |
'SAS' | SAS |
"SAS" | SAS |
"SAS's" | SAS s |
Reads character data from right to left and preserves blanks
Category: Character
See: The $REVERJ informat in SAS National Language Support (NLS): User s Guide
Reads character data from right to left and left, and then left aligns the text
Category: Character
See: The $REVERS informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in big-endian, 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
Alignment: Left
See: The $UCS2B informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in the encoding of the current SAS session and then converts the character string to big-endian, 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding
Category: Character
See: The$UCS2BE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in little-endian, 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
Alignment: Left
See: The $UCS2L informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in the encoding of the current SAS session and then converts the character string to little-endian, 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding
Category: Character
See: The $UCS2LE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
Alignment: Left
See: The $UCS2X informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in the encoding of the current SAS session and then converts the character string to 16-bit, universal character set code in 2 octets (UCS2), Unicode encoding
Category: Character
See: The $UCS2XE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in big-endian, 32-bit, universal character set code in 4 octets (UCS4), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
See: The $UCS4B informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in little-endian, 32-bit, universal character set code in 4 octets (UCS4), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
See: The $UCS4L informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in 32-bit, universal character set code in 4 octets (UCS4), Unicode encoding, and then converts the character string to the encoding of the current SAS session
Category: Character
Alignment: Left
See: The $UCS4X informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in the encoding of the current SAS session and then converts the character string to 32-bit, universal character set code in 4 octets (UCS4), Unicode encoding
Category: Character
See: The $UCX4XE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in Unicode escape (UESC) representation, and then converts the character string to the encoding of the current SAS session
Category: Character
See: The $UESC informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in the encoding of the current SAS session, and then converts the character string to Unicode escape (UESC)
Category: Character
See: The $UESCE informat in SAS National Language Support (NLS): User s Guide
Reads the numeric character representation (NCR) character string, and then converts the character string to the encoding of the current SAS session
Category: Character
See: The $UNCR informat in SAS National Language Support (NLS): User s Guide
Reads a character string in the encoding of the current SAS session, and then converts the character string to session-encoded NCR (numeric character representation)
Category: Character
See: The $UNCRE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in UPAREN (Unicode parenthesis) representation, and then converts the character string to the encoding of the current SAS session
Category: Character
See: The $UPAREN informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in the current SAS session, and then converts the character string to the encoding of the Unicode parenthesis (UPAREN) representation
Category: Character
See: The $UPARENE informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is encoded in Unicode parenthesis (UPAREN) representation, and then converts the character string to the encoding of the current SAS session with national characters remaining in the encoding of the UPAREN representation
Category: Character
See: The $UPARENP informat in SAS National Language Support (NLS): User s Guide
Converts character data to uppercase
Category: Character
$ UPCASE w.
w
specifies the width of the input field.
Default: 8 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
Special characters, such as hyphens, are not altered .
input @1 name $upcase3.;
When the Data Line = | The Result is |
---|---|
----+----1 | |
sas | SAS |
Reads a character string that is encoded in Unicode transformation format (UTF-8), and then converts the character string to the encoding of the current SAS session
Category: Character
Alignment: Left
See: The $UTF8X informat in SAS National Language Support (NLS): User s Guide
Reads character data of varying length
Valid: in a DATA step
Category: Character
$VARYING w. length-variable
w
specifies the maximum width of a character field for all the records in an input file.
Default: 8 if the length of the variable is undefined ; otherwise, the length of the variable
Range: 1 “32767
length-variable
specifies a numeric variable that contains the width of the character field in the current record. SAS obtains the value of length-variable by reading it directly from a field that is described in an INPUT statement or by calculating its value in the DATA step.
Requirement: You must specify length-variable immediately after $VARYING w . in an INPUT statement.
Restriction: Length-variable cannot be an array reference.
Tip: If the value of length-variable is 0, negative, or missing, SAS reads no data from the corresponding record. This enables you to read zero-length records and fields. If length-variable is greater than 0 but less than w , SAS reads the number of columns that are specified by length-variable . Then SAS pads the value with trailing blanks up to the maximum width that is assigned to the variable. If length-variable is greater than or equal to w , SAS reads w columns.
Use $VARYING w . when the length of a character value differs from record to record. After reading a data value with $VARYING w ., the pointer s position is set to the first column after the value.
input fwidth 1. name $varying9. fwidth;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
5shark | shark |
3sunfish | sun |
8bluefish | bluefish |
[*] Notice the result of reading the second data line. |
Use the LENGTH= option in the INFILE statement to obtain a record length indirectly. The input data lines and results follow the explanation of the SAS statements.
data one; infile file-specification length=reclen; input @; fwidth=reclen-9; input name $ 1-9 @10 class $varying20. fwidth; run;
The LENGTH= option in the INFILE statement assigns the internally stored record length to RECLEN when the first INPUT statement executes. The trailing @ holds the record for another INPUT statement. Next , the assignment statement calculates the value of the varying-length field by subtracting the fixed-length portion of the record from the total record length. The variable FWIDTH contains the length of the last field and becomes the length-variable argument to the $VARYING20. informat.
Data Lines | Results |
---|---|
----+----1----+----2 PATEL CHEMISTRY JOHNSON GEOLOGY WILCOX ART | PATEL CHEMISTRY JOHNSON GEOLOGY WILCOX ART |
Reads a character string that is in visual order and then converts the character string to left-to-right logical order
Category: BIDI text handling
See: The $VSLOG informat in SAS National Language Support (NLS): User s Guide
Reads a character string that is in visual order and then converts the character string to right-to-left logical order
Category: BIDI text handling
See: The $VSLOGR informat in SAS National Language Support (NLS): User s Guide
Reads standard character data
Category: Character
Alias: $F w .
$ w .
w
specifies the width of the input field. You must specify w because SAS does not supply a default value.
Range: 1 “32767
The $ w . informat trims leading blanks and left aligns the values before storing the text. In addition, if a field contains only blanks and a single period, $ w . converts the period to a blank because it interprets the period as a missing value. The $ w . informat treats two or more periods in a field as character data.
The $ w . informat is almost identical to the $CHAR w . informat. However, $CHAR w . does not trim leading blanks nor does it convert a single period in an input field to a blank, while $ w . does both.
input @1 name .;
When the Data Line = | The Result [*] is |
---|---|
----+----1 | |
XYZ XYZ . X YZ | XYZ## XYZ## X#YZ# |
[*] The character # represents a blank space. |
Reads and extracts date values from DATE, DATETIME, DDMMYY, JULIAN, MMDDYY, MONYY, TIME, YYMMDD, or YYQ informat values
Category: Date and Time
ANYDTDTE w .
w
specifies the width of the input field.
Default: 9
Range: 5-32
The ANYDTDTE informat reads input data that corresponds to any of the following informats. The ANYDTDTE informat extracts the date part from the derived value.
DATE
DATETIME
DDMMYY
JULIAN
MMDDYY
MONYY
TIME
YYMMDD
YYQ
If the input value is a time-only value, then SAS assumes a date of 01JAN1960.
The input values for all of the above informats are mutually exclusive except for MMDDYY, DDMMYY, and YYMMDD when two-digit years are used. It is possible for input data such as 01 “02 “03 to be ambiguous with respect to the month, day, and year. In this case, the DATESTYLE system option indicates the order of the month, day, and year.
The ANYDTDTE informat extracts the date part from the derived value. The ANYDTDTM informat extracts the datetime part. The ANYDTTME informat extracts the time part.
input dateinfo anydtdte21.;
Data Lines | Informat | Results |
---|---|---|
----+----1----+----2 | ||
14JAN1921 | DATE | ˆ’ 14231 |
14JAN1921 12:24:32.8 | DATETIME | ˆ’ 14231 |
14011921 | DDMMYY | ˆ’ 14231 |
1921014 | JULIAN | ˆ’ 14231 |
01141921 | MMDDYY | ˆ’ 14231 |
JAN1921 | MONYY | ˆ’ 14244 |
12:24:32.8 | TIME |
|
19210114 | YYMMDD | ˆ’ 14231 |
21Q1 | YYQ | ˆ’ 14244 |
Informats:
ANYDTDTM w . Informat on page 968
ANYDTTME w . Informat on page 969
Reads and extracts datetime values from DATE, DATETIME, DDMMYY, JULIAN, MMDDYY, MONYY, TIME, YYMMDD, or YYQ informat values
Category: Date and Time
ANYDTDTM w .
w
specifies the width of the input field.
Default: 19
Range: 1-32
The ANYDTDTM informat reads input data that corresponds to any of the following informats. The ANYDTDTM informat extracts the datetime part from the derived value.
DATE
DATETIME
DDMMYY
JULIAN
MMDDYY
MONYY
TIME
YYMMDD
YYQ
If the input value is a time-only value, then SAS assumes a date of 01JAN1960. If the input value is a date value only, then SAS assumes a time of 12:00 midnight.
The input values for all of the above informats are mutually exclusive except for MMDDYY, DDMMYY, or YYMMDD when two-digit years are used. It is possible for input data such as 01 “02 “03 to be ambiguous with respect to the month, day, and year. In this case, the DATESTYLE system option indicates the order of the month, day, and year.
The ANYDTDTE informat extracts the date part from the derived value. The ANYDTDTM informat extracts the datetime part. The ANYDTTME informat extracts the time part.
input dateinfo anydtdtm21.;
Data Lines | Informat | Results |
---|---|---|
----+----1----+----2 | ||
14JAN1921 | DATE | -1229558400 |
14JAN1921 12:24:32.8 | DATETIME | -1229513727 |
14011921 | DDMMYY | -1229558400 |
1921014 | JULIAN | -1229558400 |
01141921 | MMDDYY | -1229558400 |
JAN1921 | MONYY | -1230681600 |
12:24:32.8 | TIME | 44672 |
19210114 | YYMMDD | -1229558400 |
21Q1 | YYQ | -1230681600 |
Informats:
ANYDTDTE w . Informat on page 966
ANYDTTME w . Informat on page 969
Reads and extracts time values from DATE, DATETIME, DDMMYY, JULIAN, MMDDYY, MONYY, TIME, YYMMDD, or YYQ informat values
Category: Date and Time
ANYDTTME w .
w
specifies the width of the input field.
Default: 8
Range: 1-32
The ANYDTTME informat reads input data that corresponds to any of the following informats. The ANYDTTME informat extracts the time part from the derived value.
DATE
DATETIME
DDMMYY
JULIAN
MMDDYY
MONYY
TIME
YYMMDD
YYQ
If the input value is a time-only value, then SAS assumes a date of 01JAN1960. If the input value is a date value only, then SAS assumes a time of 12:00 midnight.
The input values for all of the above informats are mutually exclusive except for MMDDYY and DDMMYY when two-digit years are used. It is possible for input data such as 01 “02 “03 to be ambiguous with respect to the month, day, and year. In this case, the DATESTYLE system option indicates the order of the month, day, and year.
The ANYDTDTE informat extracts the date part from the derived value. The ANYDTDTM informat extracts the datetime part. The ANYDTTME informat extracts the time part.
input dateinfo anydttme21.;
Data Lines | Informat | Results |
---|---|---|
----+----1----+----2 | ||
14JAN1921 | DATE | 0.0 |
14JAN1921 12:24:32.8 | DATETIME | 44672.799999 |
14011921 | DDMMYY | 0.0 |
1921014 | JULIAN | 0.0 |
01141921 | MMDDYY | 0.0 |
JAN1921 | MONYY | 0.0 |
12:24:32.8 | TIME | 44672.8 |
19210114 | YYMMDD | 0.0 |
21Q1 | YYQ | 0.0 |
Informats:
ANYDTDTE w . Informat on page 966
ANYDTDTM w . Informat on page 968
Converts positive binary values to integers
Category: Numeric
BINARY w . d
w
specifies the width of the input field.
Default: 8
Range: 1 “64
d
optionally specifies the power of 10 by which to divide the value. SAS uses the d value even if the data contain decimal points.
Range: 0 “31
Use only the character digits 1 and 0 in the input, with no embedded blanks. BINARY w . d ignores leading and trailing blanks.
BINARY w . d cannot read negative values. It treats all input values as positive (unsigned).
input @1 value binary8.1;
When the data line = | The Result is |
---|---|
----+----1----+ | |
00001111 | 1.5 |
Extracts bits
Category: Numeric
BITS w . d
w
specifies the number of bits to read.
Default: 1
Range: 1 “64
d
specifies the zero-based offset.
Range: 0 “63
The BITS w . 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 you want to read.
This informat is useful for extracting data from system records that have many pieces of information packed into single bytes.
input @1 value bits4.1;
When the Data Line = | The Result [*] is |
---|---|
----+----1----+ | |
B | 8 |
[*] The 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.
Converts blanks to 0s
Category: Numeric
BZ w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The BZ w . d informat reads numeric values, converts any trailing or embedded blanks to 0s, and ignores leading blanks.
The BZ w . d informat can read numeric values that are located anywhere in the field. Blanks can precede or follow the numeric value, and a minus sign must precede negative values. The BZ w . d informat ignores blanks between a minus sign and a numeric value in an input field.
The BZ w . d informat interprets a single period in a field as a 0. The informat interprets multiple periods or other nonnumeric characters in a field as a missing value.
To use BZ w . d in a DATA step with list input, change the delimiter for list input with the DLM= option in the INFILE statement. By default, SAS interprets blanks between values in the data line as delimiters rather than 0s.
The BZ w . d informat converts trailing or embedded blanks to 0s. If you do not want to convert trailing blanks to 0s (for example, when reading values in E-notation), use either the w . d informat or the E w . d informat instead.
input @1 x bz4.;
When the Data Line = | The Result is |
---|---|
----+----1 | |
34 | 3400 |
-2 | -200 |
-2 1 | -201 |
Reads standard numeric values from column-binary files
Category: Column Binary
CB w . d
w
specifies the width of the input field.
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. SAS uses the d value even if the data contain decimal points.
The CB w . d informat reads standard numeric values from column-binary files and translates the data into standard binary format.
SAS first stores each column of column-binary data you read with CB w . d in two bytes and ignores the two high-order bits of each byte. If the punch codes are valid, SAS stores the equivalent numeric value into the variable that you specify. If the combinations are not valid, SAS assigns the variable a missing value and sets the automatic variable _ERROR_ to 1.
input @1 x cb8.;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
0009 | 9 |
[*] The data line is a hexadecimal representation of the column binary. The punch card column for the example data has row 9 punched. The binary representation is 0000 0000 0000 1001. |
Informats:
$CB w . Informat on page 948
PUNCH. d Informat on page 1010
ROW w . d Informat on page 1016
Removes embedded characters
Category: Numeric
Alias: DOLLAR w . d
COMMA w.d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The COMMA w . d informat reads numeric values and removes embedded commas, blanks, dollar signs, percent signs, dashes, and right parentheses from the input data. The COMMA w . d informat converts a left parenthesis at the beginning of a field to a minus sign.
The COMMA w . d informat operates like the COMMAX w . d informat, but it reverses the roles of the decimal point and the comma. This convention is common in European countries .
input @1 x comma10.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
$1,000,000 | 1000000 |
(500) | -500 |
Removes embedded characters
Category: Numeric
Alias: DOLLARX w . d
COMMAX w.d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain a comma, which represents a decimal point, the d value is ignored.
Range: 0 “31
The COMMAX w . d informat reads numeric values and removes embedded periods, blanks, dollar signs, percent signs, dashes, and right parentheses from the input data.
The COMMAX w . d informat converts a left parenthesis at the beginning of a field to a minus sign.
The COMMAX w . d informat operates like the COMMA w . d informat, but it reverses the roles of the decimal point and the comma. This convention is common in European countries.
input @1 x commax10.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
$1.000.000 | 1000000 |
(500) | -500 |
Reads date values in the form ddmmmyy or ddmmmyyyy
Category: Date and Time
DATE w .
w
specifies the width of the input field.
Default: 7
Range: 7 “32
Tip: Use a width of 9 to read a 4 “digit year.
The date values must be in the form ddmmmyy or ddmmmyyyy , where
dd
is an integer from 01 through 31 that represents the day of the month.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
You can separate the year, month, and day values by blanks or by special characters. Make sure the width of the input field allows space for blanks and special characters.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input calendar_date date11.;
When the data line = | The result is |
---|---|
----+----1----+ | |
16mar99 | 14319 |
16 mar 99 | 14319 |
16-mar-1999 | 14319 |
Format:
DATE w . Format on page 118
Function:
DATE Function on page 481
System Option:
YEARCUTOFF= System Option on page 1629
Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss
Category: Date and Time
DATETIME w.
w
specifies the width of the input field.
Default: 18
Range: 13 “40
The datetime values must be in the following form: ddmmmyy or ddmmmyyyy , followed by a blank or special character, followed by hh:mm:ss.ss (the time). In the date,
dd
is an integer from 01 through 31 that represents the day of the month.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
In the time,
hh
is the number of hours ranging from 00 through 23.
mm
is the number of minutes ranging from 00 through 59.
ss.ss
is the number of seconds ranging from 00 through 59 with the fraction of a second following the decimal point.
DATETIME w . requires values for both the date and the time; however, the ss.ss portion is optional.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
Note: SAS can read time values with AM and PM in them.
input date_and_time datetime20.;
When the Data Line = | The Result is |
---|---|
----+----1----+----2 | |
16mar97:11:23:07.4 | 1237202587.4 |
16mar1997/11:23:07.4 | 1237202587.4 |
16mar1997/11:23 PM | 1237245780.0 |
Formats:
DATE w . Format on page 118
DATETIME w . d Format on page 121
TIME w . d Format on page 210
Function:
DATETIME Function on page 483
Informats:
DATE w . Informat on page 977
TIME w . Informat on page 1035
System Option:
YEARCUTOFF= System Option on page 1629
See the discussion on using SAS date and time values in SAS Language Reference: Concepts
Reads date values in the form ddmmyy or ddmmyyyy
Category: Date and Time
DDMMYY w.
w
specifies the width of the input field.
Default: 6
Range: 6 “32
The date values must be in the form ddmmyy or ddmmyyyy , where
dd
is an integer from 01 through 31 that represents the day of the month.
mm
is an integer from 01 through 12 that represents the month.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
You can place blanks and other special characters between day, month, and year values. However, if you use delimiters, place them between all the values. Blanks can also be placed before and after the date. Make sure the width of the input field allows space for blanks and special characters.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input calendar_date ddmmyy10.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
160399 | 14319 |
16/03/99 | 14319 |
16 03 1999 | 14319 |
Formats:
DATE w . Format on page 118
DDMMYY w . Format on page 124
MMDDYY w . Format on page 163
YYMMDD w . Format on page 230
Function:
MDY Function on page 643
Informats:
DATE w . Informat on page 977
MMDDYY w . Informat on page 991
YYMMDD w . Informat on page 1042
System Option:
YEARCUTOFF= System Option on page 1629
Reads numeric values that are stored in scientific notation and double-precision scientific notation
Category: Numeric
See: E w . d Informat in the documentation for your operating environment.
E w.d
w
specifies the width of the field that contains the numeric value.
Default: 12
Range: 1 “32
d
optionally specifies the number of digits to the right of the decimal point in the numeric value. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The E w . d informat is not used extensively because the SAS informat for standard numeric data, the w . d informat, can read numbers in scientific notation. Use E w . d to permit only scientific notation in your input data.
input @1 x e7.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
1.257E3 | 1257 |
12d3 | 12000 |
Reads international date values
Category: Date and Time
See: The EURDFDE informat in SAS National Language Support (NLS): User s Guide
Reads international datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss
Category: Date and Time
See: The EURDFDT informat in SAS National Language Support (NLS): User s Guide
Reads month and year date values in the form mmmyy or mmmyyyy
Category: Date and Time
See: The EURDFMY informat in SAS National Language Support (NLS): User s Guide
Reads numeric values and removes embedded characters in European currency and reverses the comma and decimal point
Category: Numeric
See: The EURO informat in SAS National Language Support (NLS): User s Guide
Reads numeric values and removes embedded characters in European currency
Category: Numeric
See: The EUROX informat in SAS National Language Support (NLS): User s Guide
Reads a native single-precision, floating-point value and divides it by 10 raised to the d th power
Category: Numeric
FLOAT w . d
w
specifies the width of the input field.
Requirement: w must be 4.
d
optionally specifies the power of 10 by which to divide the value.
The FLOAT w.d informat is useful in operating environments where a float value is not the same as a truncated double.
On the IBM mainframe systems, a four-byte floating-point number is the same as a truncated eight-byte floating-point number. However, in operating environments that use the IEEE floating-point standard, such as the IBM PC-based operating environments and most UNIX platforms, a four-byte floating-point number is not the same as a truncated double. Therefore, the RB4. informat does not produce the same results as FLOAT4. Floating-point representations other than IEEE may have this same characteristic. Values read with FLOAT4. typically come from some other external program that is running in your operating environment.
The following table compares the names of float notation in several programming languages:
Language | Float Notation |
---|---|
SAS | FLOAT4. |
FORTRAN | REAL*4 |
C | float |
IBM 370 ASM | E |
PL/I | FLOAT BIN(21) |
input x float4.;
When the Data Line [*] = | The Result is |
---|---|
----+----1----+----2 | |
3F800000 | 1 |
[*] The data line is a hexadecimal representation of a binary number that is stored in IEEE form. |
Converts hexadecimal positive binary values to either integer (fixed-point) or real (floating-point) binary values
Category: Numeric
See: HEX w . Informat in the documentation for your operating environment.
HEX w.
w
specifies the field width of the input value and also specifies whether the final value is fixed-point or floating-point.
Default: 8
Range: 1 “16
Tip: If w <16, HEX w . converts the input value to positive integer binary values, treating all input values as positive (unsigned). If w is 16, HEX w . converts the input value to real binary (floating-point) values, including negative values.
Note: Different operating environments store floating-point values in different ways. However, HEX16. reads hexadecimal representations of floating-point values with consistent results if the values are expressed in the same way that your operating environment stores them.
The HEX w . informat ignores leading or trailing blanks.
input @1 x hex3. @5 y hex16.;
When the Data Line [*] = | The Result is |
---|---|
----+----1----+----2 | |
88F 4152000000000000 | 2191 5.125 |
[*] The data line shows IBM mainframe hexadecimal data. |
Reads native integer binary (fixed-point) values, including negative values
Category: Numeric
See: IB w . d Informat in the documentation for your operating environment.
IB w . d
w
specifies the width of the input field.
Default: 4
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
The IB w . d informat reads integer binary (fixed-point) values, including negative values represented in two s complement notation. IB w . d reads integer binary values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
Note: Different operating environments store integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
The IB w . d and PIB w . d informats are used to read native format integers. (Native format allows you to read and write values created in the same operating environment.) The IBR w . d and PIBR w . d informats are used to read little endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the IB informat. However, these examples use the informat with the INPUT function, where binary input values are described using a hex literal.
x=input('0080'x,ib2.); y=input('8000'x,ib2.);
When the SAS Statement is | The Result on Big Endian Platforms is | The Result on Little Endian Platforms is |
---|---|---|
put x=; | 128 | -32768 |
put y=; | -32768 | 128 |
Informat:
IBR w . d Informat on page 987
Reads integer binary (fixed-point) values in Intel and DEC formats
Category: Numeric
IBR w . d
w
specifies the width of the input field.
Default: 4
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
The IBR w . d informat reads integer binary (fixed-point) values, including negative values that are represented in two s complement notation. IBR w . d reads integer binary values that are generated by and for Intel and DEC platforms. Use IBR w . d to read integer binary data from Intel or DEC environments in other operating environments. The IBR w . d informat in SAS code allows for a portable implementation for reading the data in any operating environment.
Note: Different operating environments store integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
The IB w . d and PIB w . d informats are used to read native format integers. (Native format allows you to read and write values that are created in the same operating environment.) The IBR w . d and PIBR w . d informats are used to read little endian integers in any operating environment.
On Intel and DEC operating environments, the IB w . d and IBR w . d informats are equivalent.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the IBR informat. However, in these examples we use the informat with the INPUT function, where binary input values are described using a hex literal.
x=input('0100'x,ibr2.); y=input('0001'x,ibr2.);
When the SAS Statement is | The Result on Big Endian Platforms is | The Result on Little Endian Platforms is ... |
---|---|---|
put x=; | 1 | 1 |
put y=; | 256 | 256 |
Informat:
IB w . d Informat on page 986
Reads an IEEE floating-point value and divides it by 10 raised to the d th power
Category: Numeric
IEEE w.d
w
specifies the width of the input field.
Default: 8
Range: 2 “8
Tip: If w is 8, an IEEE double-precision, floating-point number is read. If w is 5, 6, or 7, an IEEE double-precision, floating-point number is read, which assumes truncation of the appropriate number of bytes. If w is 4, an IEEE single-precision, floating-point number is read. If w is 3, an IEEE single-precision, floating-point number is read, which assumes truncation of one byte.
d
specifies the power of 10 by which to divide the value.
The IEEE w . d informat is useful in operating environments where IEEE is the floating-point representation that is used. In addition, you can use the IEEE w . d informat to read files that are created by programs on operating environments that use the IEEE floating-point representation.
Typically, programs generate IEEE values in single precision (4 bytes) or double precision (8 bytes). Truncation is performed by programs solely to save space on output files. Machine instructions require that the floating-point number be of one of the two lengths. The IEEE w . d informat allows other lengths, which enables you to read data from files that contain space-saving truncated data.
input test1 ieee4.; input test2 ieee5.;
When the Data Line [*] is | The Result is |
---|---|
----+----1----+ | |
3F800000 | 1 |
3FF0000000 | 1 |
[*] The data lines are hexadecimal representations of binary numbers that are stored in IEEE format. |
The first INPUT statement reads the first data line, and the second INPUT statement reads the next data line.
Reads Japanese Kanji date values in the format yymmmdd or yyyymmmdd
Category: Date and Time
See: The JDATEYMD informat in SAS National Language Support (NLS): User s Guide
Reads Japanese Kanji date values in the form yymmdd
Category: Date and Time
Alignment: left
See: The JNENGO informat in SAS National Language Support (NLS): User s Guide
Reads Julian dates in the form yyddd or yyyyddd
Category: Date and Time
JULIAN w.
w
specifies the width of the input field.
Default: 5
Range: 5 “32
The date values must be in the form yyddd or yyyyddd , where
yy or yyyy
is a two-digit or four-digit integer that represents the year.
dd or ddd
is an integer from 01 through 365 that represents the day of the year.
Julian dates consist of strings of contiguous numbers, which means that zeros must pad any space between the year and the day values.
Julian dates that contain year values before 1582 are invalid for the conversion to Gregorian dates.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input julian_date julian7.;
When the Data Line = | The Result [*] is |
---|---|
----+----1 | |
99075 | 14319 |
1999075 | 14319 |
[*] The input values correspond to the seventy-fifth day of 1999, which is March 16. |
Format:
JULIAN w . Format on page 162
Functions:
DATEJUL Function on page 481
JULDATE Function on page 614
System Option:
YEARCUTOFF= System Option on page 1629
Reads dates in Taiwanese form
Category: Date and Time
See: The MINGUO informat in SAS National Language Support (NLS): User s Guide
Reads date values in the form mmddyy or mmddyyyy
Category: Date and Time
MMDDYY w.
w
specifies the width of the input field.
Default: 6
Range: 6 “32
The date values must be in the form mmddyy or mmddyyyy , where
mm
is an integer from 01 through 12 that represents the month.
dd
is an integer from 01 through 31 that represents the day of the month.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
You can separate the month, day, and year fields by blanks or by special characters. However, if you use delimiters, place them between all fields in the value. Blanks can also be placed before and after the date.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input calendar_date mmddyy8.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
031699 | 14319 |
03/16/99 | 14319 |
03 16 99 | 14319 |
03161999 | 14319 |
Formats:
DATE w . Format on page 118
DDMMYY w . Format on page 124
MMDDYY w . Format on page 163
YYMMDD w . Format on page 230
Functions:
DAY Function on page 483
MDY Function on page 643
MONTH Function on page 655
YEAR Function on page 914
Informats:
DATE w . Informat on page 977
DDMMYY w . Informat on page 980
YYMMDD w . Informat on page 1042
System Option:
YEARCUTOFF= System Option on page 1629
Reads month and year date values in the form mmmyy or mmmyyyy
Category: Date and Time
MONYY w.
w
specifies the width of the input field.
Default: 5
Range: 5 “32
The date values must be in the form mmmyy or mmmyyyy , where
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
A value read with the MONYY w . informat results in a SAS date value that corresponds to the first day of the specified month.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOF= system option.
input month_and_year monyy7.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
mar 99 | 14304 |
mar1999 | 14304 |
Formats:
DDMMYY w . Format on page 124
MMDDYY w . Format on page 163
MONYY w . Format on page 173
YYMMDD w . Format on page 230
Functions:
MONTH Function on page 655
YEAR Function on page 914
Informats:
DDMMYY w . Informat on page 980
MMDDYY w . Informat on page 991
YYMMDD w . Informat on page 1042
System Option:
YEARCUTOFF= System Option on page 1629
Reads TIME MIC values
Category: Date and Time
MSEC w .
w
specifies the width of the input field.
Requirement: w must be 8 because the OS TIME macro or the STCK System/370 instruction on IBM mainframes each return an eight-byte value.
The MSEC w . informat reads time values that are produced by IBM mainframe operating environments and converts the time values to SAS time values.
Use the MSEC w . informat to find the difference between two IBM mainframe TIME values, with precision to the nearest microsecond.
The MSEC w . and TODSTAMP w . informats both read IBM time-of-day clock values, but the MSEC w . informat assigns a time value to a variable, and the TODSTAMP w . informat assigns a datetime value.
input btime msec8.;
When the Data Line [*] = | The Result is |
---|---|
0000EA044E65A000 | 62818.412122 |
[*] The data line is a hexadecimal representation of a binary 8-byte time-of-day clock value. Each byte occupies one column of the input field. The result is a SAS time value corresponding to 5:26:58.41 PM. |
Informat:
TODSTAMP w . Informat on page 1037
Reads Japanese date values in the form eyymmdd
Category: Date and Time
See: The NENGO informat in SAS National Language Support (NLS): User s Guide
Reads the date value in the specified locale and then converts the date value to the local SAS date value
Category: Date and Time
See: NLDATEw. Informat in SAS National Language Support (NLS): User s Guide
Reads the datetime value of the specified locale, and then converts the datetime value to the local SAS datetime value
Category: Date and Time
See: NLDATMw. Informat in SAS National Language Support (NLS): User s Guide
Reads monetary data in the specified locate for the local expression, and converts the data to a numeric value
Category: Numeric
See: The NLMNY Informat in SAS National Language Support (NLS): User s Guide
Reads monetary data in the specified locale for the international expression, and then converts the data to a numeric value
Category: Numeric
See: The NLMNYI informat in SAS National Language Support (NLS): User s Guide
Reads numeric data in the specified locale for local expressions, and then converts the data to a numeric value
Category: Numeric
See: The NLNUM informat in SAS National Language Support (NLS): User s Guide
Reads numeric data in the specified locale for international expressions, and then converts the data to a numeric value
Category: Numeric
See: The NLNUMI informat in SAS National Language Support (NLS): User s Guide
Reads percentage data in the specified locale for local expressions, and then converts the data to a numeric value
Category: Numeric
See: The NLPCT informat in SAS National Language Support (NLS): User s Guide
Reads percentage data in the specified locale for international expressions, and then converts the data to a numeric value
Category: Numeric
See: The NLPCTI informat in SAS National Language Support (NLS): User s Guide
Reads the time value and uses a.m. and p.m. in the specified locale, and then converts the time value to the local SAS-time value
Category: Date and Time
See: NLTIMAPw. Informat in SAS National Language Support (NLS): User s Guide
Reads the time value in the specified locale and then converts the time value to the local SAS time value
Category: Date and Time
See: NLTIMEw. Informat in SAS National Language Support (NLS): User s Guide
Reads numeric values with a comma in place of the decimal point
Category: Numeric
NUMX w.d
w
specifies the width of the input field.
Default: 12
Range: 1 “32
d
optionally specifies the number of digits to the right of the decimal. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The NUMX w . d informat reads numeric values and interprets a comma as a decimal point.
The NUMX w . d informat is similar to the w . d informat except that it reads numeric values that contain a comma in place of the decimal point.
input @1 x numx10.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
896,48 | 896.48 |
3064,1 | 3064.1 |
6489 | 6489 |
Formats:
NUMX w . d Format on page 179
w . d Format on page 215
Converts positive octal values to integers
Category: Numeric
OCTAL w.d
w
specifies the width of the input field.
Default: 3
Range: 1 “24
d
optionally specifies the power of 10 by which to divide the value.
Range: 1 “31
Restriction: must be greater than or equal to the w value.
Use only the digits 0 through 7 in the input, with no embedded blanks. The OCTAL w . d informat ignores leading and trailing blanks.
OCTAL w . d cannot read negative values. It treats all input values as positive (unsigned).
input @1 value octal3.1;
Data Lines | Results |
---|---|
----+----1 | |
177 | 12.7 |
Reads data that are stored in IBM packed decimal format
Category: Numeric
See: PB w . d Informat in the documentation for your operating environment.
PD w.d
w
specifies the width of the input field.
Default: 1
Range: 1 “16
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
The PD w . d informat is useful because many programs write data in packed decimal format for storage efficiency, fitting two digits into each byte and using only a half byte for a sign.
Note: Different operating environments store packed decimal values in different ways. However, PD w . d reads packed decimal values with consistent results if the values are created on the same type of operating environment that you use to run SAS.
The following table compares packed decimal notation in several programming languages:
Language | Notation |
---|---|
SAS | PD4. |
COBOL | COMP-3 PIC S9(7) |
IBM 370 Assembler | PL4 |
PL/I | FIXED DEC |
input @1 x pd4.;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
0000128C | 128 |
[*] The data line is a hexadecimal representation of a binary number stored in packed decimal form. Each byte occupies one column of the input field. |
input mnth pd4.; date=input(put(mnth,6.),mmddyy6.);
Data Lines [*] | Results |
---|---|
----+----1 | |
0122599C | 14603 |
[*] The data line is a hexadecimal representation of a binary number that is stored in packed decimal form on an IBM mainframe operating environment. Each byte occupies one column of the input field. The result is a SAS date value that corresponds to December 25, 1999. |
Reads packed Julian date values in the hexadecimal form yyyyddd F for IBM
Category: Date and Time
PDJULG w.
w
specifies the width of the input field.
Default: 4
Range: 4
The PDJULG w . informat reads IBM packed Julian date values in the form of yyyyddd F, converting them to SAS date values, where
yyyy
is the two-byte representation of the four-digit Gregorian year.
ddd
is the one-and-a-half byte representation of the three-digit integer that corresponds to the Julian day of the year, 1 “365 (or 1 “366 for leap years).
F
is the half byte that contains all binary 1s, which assigns the value as positive.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input date pdjulg4.;
When Data Line = | The Result [*] is |
---|---|
----+----1 | |
1999003F | 14247 |
[*] SAS date value 14247 represents January 3, 1999. |
Formats:
JULDAY w . Format on page 161
JULIAN w . Format on page 162
PDJULG w . Format on page 182
PDJULI w . Format on page 183
Functions:
DATEJUL Function on page 481
JULDATE Function on page 614
Informats:
JULIAN w . Informat on page 990
PDJULI w . Informat on page 1003
System Option:
YEARCUTOFF= System Option on page 1629
Reads packed Julian dates in the hexadecimal format ccyyddd F for IBM
Category: Date and Time
PDJULI w.
w
specifies the width of the input field.
Default: 4
Range: 4
The PDJULI w . informat reads IBM packed Julian date values in the form ccyyddd F, converting them to SAS date values, where
cc
is the one-byte representation of a two-digit integer that represents the century.
yy
is the one-byte representation of a two-digit integer that represents the year. The PDJULI w informat makes an adjustment to the one-byte century representation by adding 1900 to the two-byte ccyy value in order to produce the correct four “digit Gregorian year. This adjustment causes ccyy values of 0098 to become 1998, 0101 to become 2001, and 0218 to become 2118.
ddd
is the one-and-a-half bytes representation of the three-digit integer that corresponds to the Julian day of the year, 1 “365 (or 1 “366 for leap years).
F
is the half byte that contains all binary 1s, which assigns the value as positive.
input date pdjuli4.;
When the Data Line = | The Result [*] is |
---|---|
----+----1 | |
0099001F | 14245 |
0110015F | 18277 |
[*] SAS date value 14245 is January 1, 1999. SAS date value 18277 is January 15, 2010. |
Formats:
JULDAY w . Format on page 161
JULIAN w . Format on page 162
PDJULG w . Format on page 182
PDJULI w . Format on page 183
Functions:
DATEJUL Function on page 481
JULDATE Function on page 614
Informats:
JULIAN w . Informat on page 990
PDJULG w . Informat on page 1001
System Option:
YEARCUTOFF= System Option on page 1629
Reads packed decimal time of SMF and RMF records
Category: Date and Time
PDTIME w .
w
specifies the width of the input field.
Requirement: w must be 4 because packed decimal time values in RMF and SMF records contain four bytes of information.
The PDTIME w . informat reads packed decimal time values that are contained in SMF and RMF records that are produced by IBM mainframe systems and converts the values to SAS time values.
The general form of a packed decimal time value in hexadecimal notation is 0 hhmmss F, where
is a half byte that contains all 0s.
hh
is one byte that represents two digits that correspond to hours.
mm
is one byte that represents two digits that correspond to minutes.
ss
is one byte that represents two digits that correspond to seconds.
F
is a half byte that contains all 1s.
If a field contains all 0s, PDTIME w . treats it as a missing value.
PDTIME w . enables you to read packed decimal time values from files that are created on an IBM mainframe on any operating environment.
input begin pdtime4.;
When the Data Line [*] = | The Result is |
---|---|
0142225F | 51745 |
[*] The data line is a hexadecimal representation of a binary time value that is stored in packed decimal form. Each byte occupies one column of the input field. The result is a SAS time value this corresponds to 2:22.25 PM. |
Reads percentages as numeric values
Category: Numeric
PERCENT w.d
w
specifies the width of the input field.
Default: 6
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The PERCENT w . d informat converts the numeric portion of the input data to a number using the same method as the COMMA w . d informat. If a percent sign (%) follows the number in the input field, PERCENT w . d divides the number by 100.
input @1 x percent3. @4 y percent5.;
When the Data Line = | The Result is |
---|---|
----+----1----+ | |
1% (20%) | 0.01 - 0.2 |
Reads positive integer binary (fixed-point) values
Category: Numeric
See: PIB w . d Informat in the documentation for your operating environment.
PIB w.d
w
specifies the width of the input field.
Default: 1
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
All values are treated as positive. PIB w . d reads positive integer binary values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
Note: Different operating environments store positive integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
Positive integer binary values are the same as integer binary values except that the sign bit is part of the value, which is always a positive integer. The PIB w . d informat treats all values as positive and includes the sign bit as part of the value.
The PIB w . d informat with a width of 1 results in a value that corresponds to the binary equivalent of the contents of a byte. This is useful if your data contain values between hexadecimal 80 and hexadecimal FF, where the high-order bit can be misinterpreted as a negative sign.
The IB w . d and PIB w . d informats are used to read native format integers. (Native format allows you to read and write values that are created in the same operating environment.) The IBR w . d and PIBR w . d informats are used to read little endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the PIB informat. However, in these examples we use the informat with the INPUT function, where binary input values are described by using a hex literal.
x=input('0100'x,pib2.); y=input('0001'x,pib2.);
When the SAS Statement is | The Result on Big Endian Platforms is | The Result on Little Endian Platforms is |
---|---|---|
put x=; | 256 | 1 |
put y=; | 1 | 256 |
Informat:
PIBR w . d Informat on page 1008
Reads positive integer binary (fixed-point) values in Intel and DEC formats
Category: Numeric
PIBR w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
All values are treated as positive. PIBR w . d reads positive integer binary values that have been generated by and for Intel and DEC operating environments. Use PIBR w . d to read positive integer binary data from Intel or DEC environments on other operating environments. The PIBR w . d informat in SAS code allows for a portable implementation for reading the data in any operating environment.
Note: Different operating environments store positive integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
Positive integer binary values are the same as integer binary values except that the sign bit is part of the value, which is always a positive integer. The PIBR w . d informat treats all values as positive and includes the sign bit as part of the value.
The PIBR w . d informat with a width of 1 results in a value that corresponds to the binary equivalent of the contents of a byte. This is useful if your data contain values between hexadecimal 80 and hexadecimal FF, where the high-order bit can be misinterpreted as a negative sign.
On Intel and DEC platforms, the PIB w . d and PIBR w . d informats are equivalent.
The IB w . d and PIB w . d informats are used to read native format integers. (Native format allows you to read and write values that are created in the same operating environment.) The IBR w . d and PIBR w . d informats are used to read little endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the PIBR informat. However, these examples use the informat with the INPUT function, where binary input values are described using a hex literal.
x=input('0100'x,pibr2.); y=input('0001'x,pibr2.);
When the SAS Statement is | The Result on Big Endian Platforms is | The Result on Little Endian Platforms is |
---|---|---|
put x=; | 1 | 1 |
put y=; | 256 | 256 |
Informat:
PIB w . d Informat on page 1006
Reads unsigned packed decimal data
Category: Numeric
PK w.d
w
specifies the number of bytes of unsigned packed decimal data, each of which contains two digits.
Default: 1
Range: 1 “16
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Each byte of unsigned packed decimal data contains two digits.
The PK w . d informat is the same as the PD w . d informat, except that PK w . d treats the sign half of the field s last byte as part of the value, not as the sign of the value.
input @1 x pk3.;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
001234 | 1234 |
[*] The data line is a hexadecimal representation of a binary number stored in unsigned packed decimal form. Each byte occupies one column of the input field. |
Reads whether a row of column-binary data is punched
Category: Column Binary
PUNCH .d
d
specifies which row in a card column to read.
Range: 1 “12
This informat assigns the value 1 to the variable if row d of the current card column is punched, or 0 if row d of the current card column is not punched. After PUNCH. d reads a field, the pointer does not advance to the next column.
When the Data Line [*] = | And the SAS Statement is | The Result is |
---|---|---|
12-7-8 | input x punch.12 | 1 |
input x punch.11 |
| |
input x punch0.7 | 1 | |
[*] The data line is punched card code. The punch card column for the example data has row 12, row 7, and row 8 punched. |
Informats:
$CB w . Informat on page 948
CB w . d Informat on page 974
ROW w . d Informat on page 1016
Reads numeric data that are stored in real binary (floating-point) notation
Category: Numeric
See: RB w . d Informat in the documentation for your operating environment.
RB w.d
w
specifies the width of the input field.
Default: 4
Range: 2 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Note: Different operating environments store real binary values in different ways. However, the RB w . d informat reads real binary values with consistent results if the values are created on the same type of operating environment that you use to run SAS.
The following table compares the names of real binary notation in several programming languages:
Real Binary Notation | ||
---|---|---|
Language | 4 Bytes | 8 Bytes |
SAS | RB4. | RB8. |
FORTRAN | REAL * 4 | REAL * 8 |
C | float | double |
IBM 370 assembler | F | D |
PL/I | FLOAT BIN(21) | FLOAT BIN(53) |
CAUTION:
Using the RBw.d informat to read real binary information on equipment that conforms to the IEEE standard for floating-point numbers results in a truncated eight-byte number (double-precision), rather than in a true four-byte floating-point number (single-precision).
input @1 x rb8.;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
4280000000000000 | 128 |
[*] The data line is a hexadecimal representation of a real binary (floating-point) number on an IBM mainframe operating environment. Each byte occupies one column of the input field. |
Informat:
IEEE w . d Informat on page 988
Reads duration intervals of RMF records
Category: Date and Time
RMFDUR w .
w
specifies the width of the input field.
Requirement: w must be 4 because packed decimal duration values in RMF records contain four bytes of information.
The RMFDUR w . informat reads the duration of RMF measurement intervals of RMF records that are produced as packed decimal data by IBM mainframe systems and converts them to SAS time values.
The general form of the duration interval data in an RMF record in hexadecimal notation is mmssttt F, where
mm
is the one-byte representation of two digits that correspond to minutes.
ss
is the one-byte representation of two digits that correspond to seconds.
ttt
is the one-and-a-half-bytes representation of three digits that correspond to thousandths of a second.
F
is a half byte that contains all binary 1s, which assigns the value as positive.
If the field does not contain packed decimal data, RMFDUR w . results in a missing value.
Both the RMFDUR w . informat and the RMFSTAMP w . informat read packed decimal information from RMF records that are produced by IBM mainframe systems.
The RMFDUR w . informat reads duration data and results in a time value.
The RMFSTAMP w . informat reads time-of-day data and results in a datetime value.
input dura rmfdur4.;
When the data line [*] = | The result is |
---|---|
----+----1----+ | |
3552226F | 2152.226 |
[*] The data line is a hexadecimal representation of a binary duration value that is stored in packed decimal form as it would appear in an RMF record. Each byte occupies one column of the input field. The result is a SAS time value corresponding to 00:35:52.226. |
Informats:
RMFSTAMP w . Informat on page 1014
SMFSTAMP w . Informat on page 1033
Reads time and date fields of RMF records
Category: Date and Time
RMFSTAMP w .
w
specifies the width of the input field.
Requirement: w must be 8 because packed decimal time and date values in RMF records contain eight bytes of information: four bytes of time data that are followed by four bytes of date data.
The RMFSTAMP w . informat reads packed decimal time and date values of RMF records that are produced by IBM mainframe systems, and converts the time and date values to SAS datetime values.
The general form of the time and date information in an RMF record in hexadecimal notation is 0 hhmmss F ccyyddd F, where
is the half byte that contains all binary 0s.
hh
is the one-byte representation of two digits that correspond to the hour of the day.
mm
is the one-byte representation of two digits that correspond to minutes.
ss
is 1 byte that represents two digits that correspond to seconds.
cc
is the one-byte representation of two digits that correspond to the century.
yy
is the one-byte representation of two digits that correspond to the year.
ddd
is the one-and-a-half bytes that contain three digits that correspond to the day of the year.
F
is the half byte that contains all binary 1s.
The century indicators 00 correspond to 1900, 01 to 2000, and 02 to 2100.
RMFSTAMP w . enables you to read, on any operating environment, packed decimal time and date values from files that are created on an IBM mainframe.
Both the RMFSTAMP w . informat and the PDTIME w . informat read packed decimal values from RMF records. The RMFSTAMP w . informat reads both time and date values and results in a SAS datetime value. The PDTIME w . informat reads only time values and results in a SAS time value.
input begin rmfstamp8.;
When the Data Line [*] = | The Result is |
---|---|
----+----1----+----2 | |
0142225F0102286F | 1350138145 |
[*] The data line is a hexadecimal representation of a binary time and date value that is stored in packed decimal form as it would appear in an RMF record. Each byte occupies one column of the input field. The result is a SAS datetime value that corresponds to October 13, 2002, 2:22.25 PM. |
Reads a column-binary field down a card column
Category: Column Binary
ROW w.d
w
specifies the row where the field begins.
Range: 0 “12
d
specifies the length in rows of the field.
Default: 1
Range: 1 “25
The ROW w . d informat assigns the relative position of the punch in the field to a numeric variable.
If the field that you specify has more than one punch, ROW w . d assigns the variable a missing value and sets the automatic variable _ERROR_ to 1. If the field has no punches, ROW w . d assigns the variable a missing value.
ROW w . d can read fields across columns, continuing with row 12 of the new column and going down through the rest of the rows. After ROW w . d reads a field, the pointer moves to the next row.
input x row5.3 input x row7.1 input x row5.2 input x row3.5
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
00 | |
04 | 3 |
1 | |
. | |
5 | |
[*] The data line is a hexadecimal representation of the column binary. The punch card column for the example data has row 7 punched. The binary representation is 0000 0000 0000 0100. |
Informats:
$CB w . Informat on page 948
CB w . d Informat on page 974
PUNCH. d Informat on page 1010
Reads EBCDIC numeric data
Category: Numeric
S370FF w . d
w
specifies the width of the input field.
Default: 12
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “31
The S370FF w . d informat reads numeric data that are represented in EBCDIC and converts the data to native format. If EBCDIC is the native format, S370FF w . d performs no conversion.
S370FF w . d reads EBCDIC numeric values that are represented with one byte per digit. Use S370FF w . d on other operating environments to read numeric data from IBM mainframe files.
S370FF w . d reads numeric values located anywhere in the input field. EBCDIC blanks can precede or follow a numeric value with no effect. If a value is negative, an EBCDIC minus sign should immediately precede the value. S370FF w . d reads values with EBCDIC decimal points and values in scientific notation, and it interprets a single EBCDIC period as a missing value.
The S370FF w . d informat performs the same role for numeric data that the $EBCDIC w . d informat does for character data. That is, on an IBM mainframe system, S370FF w . d has the same effect as the standard w . d informat. On all other systems, using S370FF w . d is equivalent to using $EBCDIC w . d as well as using the standard w . d informat.
input @1 x s370ff3.;
When the Data Line [*] is | The Result is |
---|---|
----+----1 | |
F1F2F3 | 123 |
F2F4F0 | 240 |
[*] The data lines are hexadecimal representations of codes for characters. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one character value. |
Reads integer binary (fixed-point) values, including negative values, in IBM mainframe format
Category: Numeric
S370FIB w . d
w
specifies the width of the input field.
Default: 4
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
The S370FIB w . d informat reads integer binary (fixed-point) values that are stored in IBM mainframe format, including negative values that are represented in two s complement notation. S370FIB w . d reads integer binary values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
Use S370FIB w . d for integer binary data that are created in IBM mainframe format for reading in other operating environments.
Note: Different operating environments store integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
If you use SAS on an IBM mainframe, S370FIB w . d and IB w . d are identical.
S370FPIB w . d , S370FIBU w . d , and S370FIB w . d are used to read big endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the S370FIB informat. However, this example uses the informat with the INPUT function, where the binary input value is described by using a hex literal.
x=input('0080'x,s370fib2.);
If the SAS Statement is | The Result is |
---|---|
put x=; | 128 |
Informats:
S370FIBU w . d Informat on page 1020
S370FPIB w . d Informat on page 1023
Reads unsigned integer binary (fixed-point) values in IBM mainframe format
Category: Numeric
S370FIBU w . d
w
specifies the width of the input field.
Default: 4
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value. SAS uses the d value even if the data contain decimal points.
Range: 0 “10
The S370FIBU w . d informat reads unsigned integer binary (fixed-point) values that are stored in IBM mainframe format, including negative values that are represented in two s complement notation. Unsigned integer binary values are the same as integer binary values, except that all values are treated as positive. S370FIBU w . d reads integer binary values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
Use S370FIBU w . d for unsigned integer binary data that are created in IBM mainframe format for reading in other operating environments.
Note: Different operating environments store integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
The S370FIBU w.d informat is equivalent to the COBOL notation PIC 9( n ) BINARY, where n is the number of digits.
The S370FIBU w . d and S370FPIB w . d informats are identical.
S370FPIB w . d , S370FIBU w . d , and S370FIB w . d are used to read big endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the S370FIBU informat. However, these examples use the informat with the INPUT function, where binary input values are described by using a hex literal.
x=input('7F'x,s370fibu1.); y=input('F6'x,s370fibu1.);
When the SAS Statement is | The Result is |
---|---|
put x=; | 127 |
put y=; | 246 |
Informats:
S370FIB w . d Informat on page 1018
S370FPIB w . d Informat on page 1023
Reads packed data in IBM mainframe format
Category: Numeric
S370FPD w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “16
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Packed decimal data contain two digits per byte, but only one digit in the input field represents the sign. The last half of the last byte indicates the sign: a C or an F for positive numbers and a D for negative numbers.
Use S370FPD w . d to read packed decimal data from IBM mainframe files on other operating environments.
If you use SAS on an IBM mainframe, the S370FPD w . d and the PD w . d informats are identical.
The following table compares the equivalent packed decimal notation by programming language:
Language | Packed Decimal Notation |
---|---|
SAS | S370FIB4. |
PL/I | FIXED DEC(7,0) |
COBOL | COMP-3 PIC 9(7) |
assembler | PL4 |
Reads unsigned packed decimal data in IBM mainframe format
Category: Numeric
S370FPDU w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “16
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Packed decimal data contain two digits per byte. The last half of the last byte, which indicates the sign for signed packed data, is always F for unsigned packed data.
Use S370FPDU w . d on other operating environments to read unsigned packed decimal data from IBM mainframe files.
The S370FPDU w . d informat is similar to the S370FPD w . d informat except that the S370FPDU w . d informat rejects all sign digits except F.
The S370FPDU w . d informat is equivalent to the COBOL notation PIC 9( n ) PACKED-DECIMAL, where the n value is the number of digits.
input @1 x s370fpdu3.;
When the Data Line [*] = | The Result is |
---|---|
----+----1 | |
12345F | 12345 |
[*] The data line is a hexadecimal representation of a binary number that is stored in packed decimal form. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Reads positive integer binary (fixed-point) values in IBM mainframe format
Category: Numeric
S370FPIB w . d
w
specifies the width of the input field.
Default: 4
Range: 1 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Positive integer binary values are the same as integer binary values, except that all values are treated as positive. S370FPIB w . d reads integer binary values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
Use S370FPIB w . d for positive integer binary data that are created in IBM mainframe format for reading in other operating environments.
Note: Different operating environments store integer binary values in different ways. This concept is called byte ordering. For a detailed discussion about byte ordering, see Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms on page 933.
If you use SAS on an IBM mainframe, S370FPIB w . d and PIB w . d are identical.
S370FPIB w . d , S370FIBU w . d , and S370FIB w . d are used to read big endian integers in any operating environment.
To view a table that shows the type of informat to use with big endian and little endian integers, see Table 5.1 on page 934.
To view a table that compares integer binary notation in several programming languages, see Table 5.2 on page 934.
You can use the INPUT statement and specify the S370FPIB informat. However, this example uses the informat with the INPUT function, where the binary input value is described using a hex literal.
x=input('0100'x,s370fpib2.);
When the SAS Statement is | The Result is |
---|---|
put x=; | 256 |
Informats:
S370FIB w . d Informat on page 1018
S370FIBU w . d Informat on page 1020
Reads real binary (floating-point) data in IBM mainframe format
Category: Numeric
S370FRB w . d
w
specifies the width of the input field.
Default: 6
Range: 2 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Real binary values are represented in two parts : a mantissa that gives the value, and an exponent that gives the value s magnitude.
Use S370FRB w . d to read real binary data from IBM mainframe files on other operating environments.
If you use SAS on an IBM mainframe, S370FRB w . d and RB w . d are identical.
The following table shows the equivalent real binary notation for several programming languages:
Real Binary Notation | ||
---|---|---|
Language | 4 Bytes | 8 Bytes |
SAS | S370FRB4. | S370FRB8. |
PL/I | FLOAT BIN(21) | FLOAT BIN(53) |
FORTRAN | REAL*4 | REAL*8 |
COBOL | COMP-1 | COMP-2 |
assembler | E | D |
C | float | double |
Informat:
RB w . d Informat on page 1011
Reads zoned decimal data in IBM mainframe format
Category: Numeric
S370FZD w . d
w
specifies the width of the input field.
Default: 8
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain decimal points, the d value is ignored.
Range: 0 “10
Zoned decimal data are similar to standard decimal data in that every digit requires one byte. However, the value s sign is stored in the last byte, along with the last digit.
Use S370FZD w . d on other operating environments to read zoned decimal data from IBM mainframe files.
If you use SAS on an IBM mainframe, S370FZD w . d and ZD w . d are identical.
The following table shows the equivalent zoned decimal notation for several programming languages:
Language | Zoned Decimal Notation |
---|---|
SAS | S370FZD3. |
PL/I | PICTURE 99T |
COBOL | PIC S9(3) DISPLAY |
assembler | ZL3 |
input @1 x s370fzd3.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F1F2C3 | 123 |
F1F2D3 | - 123 |
[*] The data line contains a hexadecimal representation of a binary number stored in zoned decimal format on an IBM mainframe operating environment. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Informat:
ZD w . d Informat on page 1046
Reads zoned decimal leading-sign data in IBM mainframe format
Category: Numeric
S370FZDL w . d
w
specifies the width of the input field.
Default: 8
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Use S370FZDL w . d on other operating environments to read zoned decimal data from IBM mainframe files.
Zoned decimal leading-sign data is similar to standard zoned decimal data except that the sign of the value is stored in the first byte of zoned decimal leading-sign data, along with the first digit.
The S370FZDL w . d informat is equivalent to the COBOL notation PIC S9( n ) DISPLAY SIGN LEADING, where the n value is the number of digits.
input @1 x s370fzdl3.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
C1F2F3 | 123 |
D1F2F3 | -123 |
[*] The data lines contain a hexadecimal representation of a binary number stored in zoned decimal format on an IBM mainframe operating environment. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Reads zoned decimal separate leading-sign data in IBM mainframe format
Category: Numeric
S370FZDS w . d
w
specifies the width of the input field.
Default: 8
Range: 2 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Use S370FZDS w . d on other operating environments to read zoned decimal data from IBM mainframe files.
Zoned decimal separate leading-sign data is similar to standard zoned decimal data except that the sign of the value is stored in the first byte of zoned decimal leading sign data, and the first digit of the value is stored in the second byte.
The S370FZDS w . d informat is equivalent to the COBOL notation PIC S9( n ) DISPLAY SIGN LEADING SEPARATE, where the n value is the number of digits.
input @1 x s370fzds4.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
4EF1F2F3 | 123 |
60F1F2F3 | -123 |
[*] The data line contains a hexadecimal representation of a binary number that is stored in zoned decimal format on an IBM mainframe operating environment. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Reads zoned decimal separate trailing-sign data in IBM mainframe format
Category: Numeric
S370FZDT w . d
w
specifies the width of the input field.
Default: 8
Range: 2 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Use S370FZDT w . d on other operating environments to read zoned decimal data from IBM mainframe files.
Zoned decimal separate trailing-sign data are similar to zoned decimal separate leading-sign data except that the sign of the value is stored in the last byte of zoned decimal separate trailing-sign data.
The S370FZDT w . d informat is equivalent to the COBOL notation PIC S9( n ) DISPLAY SIGN TRAILING SEPARATE, where the n value is the number of digits.
input @1 x s370fzdt4.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F1F2F34E | 123 |
F1F2F360 | -123 |
[*] The data line contains a hexadecimal representation of a binary number that is stored in zoned decimal format on an IBM mainframe operating environment. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Reads unsigned zoned decimal data in IBM mainframe format
Category: Numeric
S370FZDU w . d
w
specifies the width of the input field.
Default: 8
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Use S370FZDU w . d on other operating environments to read unsigned zoned decimal data from IBM mainframe files.
The S370FZDU w . d informat is similar to the S370FZD w . d informat except that the S370FZDU w . d informat rejects all sign digits except F.
The S370FZDU w . d informat is equivalent to the COBOL notation PIC 9( n ) DISPLAY, where the n value is the number of digits.
input @1 x s370fzdu3.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F1F2F3 | 123 |
[*] The data line contains a hexadecimal representation of a binary number that is stored in zoned decimal format on an IBM mainframe operating environment. Each two hexadecimal digits correspond to one byte of binary data, and each byte corresponds to one column of the input field. |
Reads date and time values of SHR records
Category: Date and Time
SHRSTAMP w .
w
specifies the width of the input field.
Requirement: w must be 8 because packed decimal date and time values in SHR records contain eight bytes of information: four bytes of date data that are followed by four bytes of time data.
The SHRSTAMP w . informat reads packed decimal date and time values of SHR records that are produced by IBM mainframe environments and converts the date and time values to SAS datetime values.
The general form of the date and time information in an SHR record in hexadecimal notation is ccyyddd F hhmmssth , where
ccyy
is the two byte representation of the year. The cc portion is the one byte representation of a two-digit integer that represents the century. The yy portion is the one byte representation of two digits that correspond to the year.
The cc portion is the century indicator where 00 indicates 19yy, 01 indicates 20yy, 02 indicates 21yy and so on. A hex year value of 0115 is equal to the year 2015.
ddd
is the one-and-a-half bytes that contain three digits that correspond to the day of the year.
F
is the half byte that contains all binary 1s.
hh
is the one byte representation of two digits that correspond to the hour of the day.
mm
is the one byte representation of two digits that correspond to minutes.
ss
is the one byte representation of two digits that correspond to seconds.
th
is the one byte representation of two digits that correspond to a hundredth of a second.
The SHRSTAMP w . informat enables you to read, on any operation environment, packed decimal date and time values from files that are created on an IBM mainframe.
input begin shrstamp8.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1----+----2 | |
0097239F12403576 | 1188304835.8 |
[*] The data line is a hexadecimal representation of a packed decimal date and time value that is stored as it would appear in an SHR record. Each byte occupies one column of the input field. The result is a SAS datetime value that corresponds to Aug. 27, 1997 12:40:36 PM. |
Reads time and date values of SMF records
Category: Date and Time
SMFSTAMP w .
w
specifies the width of the input field.
Requirement: w must be 8 because time and date values in SMF records contain eight bytes of information: four bytes of time data that are followed by four bytes of date data.
Tip: The time portion of an SMF record is a four-byte integer binary number that represents time as the number of hundredths of a second past midnight.
The SMFSTAMP w . informat reads integer binary time values and packed decimal date values of SMF records that are produced by IBM mainframe systems and converts the time and date values to SAS datetime values.
The date portion of an SMF record in hexadecimal notation is ccyyddd F, where
cc
is the one-byte representation of two digits that correspond to the century.
yy
is the one-byte representation of two digits that correspond to the year.
ddd
is the one-and-a-half bytes that contain three digits that correspond to the day of the year.
F
is the half byte that contains all binary 1s.
The SMFSTAMP w . informat enables you to read, on any operating environment, integer binary time values and packed decimal date values from files that are created on an IBM mainframe.
input begin smfstamp8.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1----+----2 | |
0058DC0C0098200F | 1216483835 |
[*] The data line is a hexadecimal representation of a binary time and date value that is stored as it would appear in an SMF record. Each byte occupies one column of the input field. The result is a SAS datetime value that corresponds to July 19, 1998 4:10:35 PM. |
Reads time values and determines whether the values are hours, minutes, or seconds; reads the output of the STIMER system option
Category: Date and Time
STIMER w .
w
specifies the width of the input field.
The STIMER informat reads performance statistics that the STIMER system option writes to the SAS log.
The informat reads time values and determines whether the values are hours, minutes, or seconds based on the presence of decimal points and colons:
If no colon is present, the value is the number of seconds.
If a single colon is present, the value before the colon is the number of minutes. The value after the colon is the number of seconds.
If two colons are present, the sequence of time is hours, minutes, and then seconds.
In all cases, the result is a SAS time value.
The input values for STIMER must be in one of the following forms:
ss
ss.ss
mm:ss
mm:ss.ss
hh:mm:ss
hh:mm:ss.ss
where
ss
is an integer that represents the number of seconds.
mm
is an integer that represents the number of minutes.
hh
is an integer that represents the number of hours.
Reads hours, minutes, and seconds in the form hh:mm:ss.ss
Category: Date and Time
TIME w.
w
specifies the width of the input field.
Default: 8
Range: 5 “32
Time values must be in the form hh:mm:ss.ss , where
hh
is an integer.
mm
is the number of minutes that range from 00 through 59.
ss.ss
is the number of seconds ranging from 00 through 59 with the fraction of a second following the decimal point.
Separate hh , mm , and ss.ss with a special character. If you do not enter a value for seconds, SAS assumes a value of 0.
The stored value is the total number of seconds in the time value.
input begin time10.;
When the Data Line = ... | The Result is ... |
---|---|
----+----1----+ | |
11:23:07.4 | 40987.4 |
The TIME informat can read time values with AM or PM in the value.
input begin time8.;
Data Lines | Results |
---|---|
----+----1----+ | |
1:13 PM | 47580.0 |
Formats:
HHMM w . d Format on page 155
HOUR w . d Format on page 156
MMSS w . d Format on page 167
TIME w . d Format on page 210
Functions:
HOUR Function on page 579
MINUTE Function on page 647
SECOND Function on page 819
TIME Function on page 855
Reads an eight-byte time-of-day stamp
Category: Date and Time
TODSTAMP w .
w
specifies the width of the input field.
Requirement: w must be 8 because the OS TIME macro or the STCK instruction on IBM mainframes each return an eight-byte value.
The TODSTAMP w . informat reads time-of-day clock values that are produced by IBM mainframe operating systems and converts the clock values to SAS datetime values.
If the time-of-day value is all 0s, TODSTAMP w . results in a missing value.
Use TODSTAMP w . on other operating environments to read time-of-day values that are produced by an IBM mainframe.
input btime todstamp8.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1----+----2 | |
B361183D5FB80000 | 1262303998 |
[*] The data line is a hexadecimal representation of a binary, 8-byte time-of-day clock value. Each byte occupies one column of the input field. The result is a SAS datetime value that corresponds to December 31, 1999, 11:59:58 PM. |
Reads a trailing plus (+) or minus (-) sign
Category: Numeric
TRAILSGN w .
w
specifies the width of the input field.
Default: 6
Range: 1 “32
If the data contains a decimal point, then the TRAILSGN informat honors the number of decimal places that are in the input data.
input x trailsgn8.;
When the data line is... | The result is... |
---|---|
----+----1----+ | |
1 | 1 |
1+ | 1 |
1- | -1 |
1.2 | 1.2 |
1.2+ | 1.2 |
1.2 | -1.2 |
Reads timer units
Category: Date and Time
TU w .
w
specifies the width of the input field.
Requirement: w must be 4 because the OS TIME macro returns a four-byte value.
The TU w . informat reads timer unit values that are produced by IBM mainframe operating environments and converts the timer unit values to SAS time values.
There are exactly 38,400 software timer units per second. The low-order bit in a timer unit value represents approximately 26.041667 microseconds.
Use the TU w . informat to read timer unit values that are produced by an IBM mainframe on other operating environments.
input btime tu4.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1----+ | |
8FC7A9BC | 62818.411563 |
[*] The data line is a hexadecimal representation of a binary, four-byte timer unit value. Each byte occupies one column of the input field. The result is a SAS time value that corresponds to 5:26:58.41 PM. |
Reads real binary (floating-point) data in VMS format
Category: Numeric
VAXRB w.d
w
specifies the width of the input field.
Default: 4
Range: 2 “8
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “10
Use the VAXRB w . d informat to read floating-point data from VMS files on other operating environments.
If you use SAS that is running under VMS, the VAXRB w . d and the RB w . d informats are identical.
Informat:
RB w . d Informat on page 1011
Reads standard numeric data
Category: Numeric
Alias: BEST w.d , D w.d , E w.d , F w.d
w.d
w
specifies the width of the input field.
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value. If the data contain decimal points, the d value is ignored.
Range: 0 “31
The w . d informat reads numeric values that are located anywhere in the field. Blanks can precede or follow a numeric value with no effect. A minus sign with no separating blank should immediately precede a negative value. The w . d informat reads values with decimal points and values in scientific E-notation, and it interprets a single period as a missing value.
The w . d informat is identical to the BZ w . d informat, except that the w . d informat ignores trailing blanks in the numeric values. To read trailing blanks as 0s, use the BZ w . d informat.
The w . d informat can read values in scientific E-notation exactly as the E w . d informat does.
input @1 x 6. @10 y 6.2; put x @7 y;
When the Data Line = ... | The Result is ... |
---|---|
----+----1----+----+ 23 2300 23 2300 23 2300 23.0 23. 2.3E1 2.3 23 0 | 23 23 23 23 23 23 23 23 23 2.3 23 0 |
Reads the format of the number-of-week value within the year and returns a SAS date value by using the U algorithm
Category: Date and Time
See: The WEEKU informat in SAS National Language Support (NLS): User s Guide
Reads the format of the number-of-week value within the year and returns a SAS date value using the V algorithm
Category: Date and Time
See: The WEEKV informat in SAS National Language Support (NLS): User s Guide
Reads the format of the number-of-week value within the year and returns a SAS date value using the W algorithm
Category: Date and Time
See: The WEEKW informat in SAS National Language Support (NLS): User s Guide
Removes embedded yen signs, commas, and decimal points
Category: Numeric
See: The YEN informat in SAS National Language Support (NLS): User s Guide
Reads date values in the form yymmdd or yyyymmdd
Category: Date and Time
YYMMDD w.
w
specifies the width of the input field.
Default: 6
Range: 6 “32
The date values must be in the form yymmdd or yyyymmdd , where
yy or yyyy
is a two-digit or four-digit integer that represents the year.
mm
is an integer from 01 through 12 that represents the month of the year.
dd
is an integer from 01 through 31 that represents the day of the month.
You can separate the year, month, and day values by blanks or by special characters. However, if delimiters are used, place them between all the values. You can also place blanks before and after the date. Make sure the width of the input field allows space for blanks and special characters.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input calendar_date yymmdd10.;
When the Data Line = ... | The Result is ... |
---|---|
----+----1----+ | |
050316 | 16511 |
05/03/16 | 16511 |
05 03 16 | 16511 |
2005-03-16 | 16511 |
Formats:
DATE w . Format on page 118
DDMMYY w . Format on page 124
MMDDYY w . Format on page 163
YYMMDD w . Format on page 230
Functions:
DAY Function on page 483
MDY Function on page 643
MONTH Function on page 655
YEAR Function on page 914
Informats:
DATE w . Informat on page 977
DDMMYY w . Informat on page 980
MMDDYY w . Informat on page 991
System Option:
YEARCUTOFF= System Option on page 1629
Reads date values in the form yyyymm or yymm
Category: Date and Time
YYMMN w.
w
specifies the width of the input field.
Default: 4
Range: 4 “6
The date values must be in the form yyyymm or yymm , where
yy or yyyy
is a two-digit or four-digit integer that represents the year.
mm
is a two-digit integer that represents the month.
The N in the informat name must be used and indicates that you cannot separate the year and month values by blanks or by special characters. SAS automatically adds a day value of 01 to the value to make a valid SAS date variable.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input date1 yymmn6.;
When the Data Line = ... | The Result is ... |
---|---|
----+----1----+ | |
200508 | 16649 |
Formats:
DATE w . Format on page 118
DDMMYY w . Format on page 124
YYMMDD w . Format on page 230
YYMM w . Format on page 227
YYMON w . Format on page 233
Functions:
DAY Function on page 483
MONTH Function on page 655
MDY Function on page 643
YEAR Function on page 914
Informats:
DATE w . Informat on page 977
DDMMYY w . Informat on page 980
MMDDYY w . Informat on page 991
YYMMDD w . Informat on page 1042
System Option:
YEARCUTOFF= System Option on page 1629
Reads quarters of the year in the form yy Q q or yyyy Q q
Category: Date and Time
YYQ w.
w
specifies the width of the input field.
Default: 6 (For SAS version 6, the default is 4.)
Range: 4 “32 (For SAS version 6, the range is 4 “6.)
The quarter must be in the form yy Q q or yyyy Q q , where
yy or yyyy
is an integer that represents the two-digit or four-digit year.
q
is an integer (1, 2, 3, or 4) that represents the quarter of the year. You can also represent the quarter as 01, 02, 03, or 04.
The letter Q must separate the year value and the quarter value. The year value, the letter Q, and the quarter value cannot be separated by blanks. A value that is read with YYQ w. produces a SAS date value that corresponds to the first day of the specified quarter.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
input quarter yyq9.;
When the Data Line = ... | The Result is ... |
---|---|
----+----1----+ | |
05Q2 | 16527 |
05Q02 | 16527 |
2005Q02 | 16527 |
Functions:
QTR Function on page 760
YEAR Function on page 914
YYQ Function on page 918
System Option:
YEARCUTOFF= System Option on page 1629
Reads zoned decimal data
Category: Numeric
See: ZD w . d Informat in the documentation for your operating environment.
ZD w.d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 1 “31
The ZD w . d informat reads zoned decimal data in which every digit requires one byte and in which the last byte contains the value s sign along with the last digit.
Note: Different operating environments store zoned decimal values in different ways. However, ZD w . d reads zoned decimal values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
You can enter positive values in zoned decimal format from a terminal. Some keying devices enable you to enter negative values by overstriking the last digit with a minus sign.
Like the w . d informat, the ZD w . d informat reads data in which every digit requires one byte. Use ZDV w . d or ZD w . d to read zoned decimal data in which the last byte contains the last digit and the sign.
The ZD w . d informat functions like the ZDV w . d informat with one exception: ZDV w . d validates the input string and disallows invalid data.
The following table compares the zoned decimal informat with notation in several programming languages:
Language | Zoned Decimal Notation |
---|---|
SAS | ZD3. |
PL/I | PICTURE 99T |
COBOL | DISPLAY PIC S 999 |
IBM 370 assembler | ZL3 |
input @1 x zd4.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F0F1F2C8 | 128 |
[*] The data line contains a hexadecimal representation of a binary number that is stored in zoned decimal format on an IBM mainframe computer system. Each byte occupies one column of the input field. |
Informats:
w . d Informat on page 1040
ZDV w . d Informat on page 1048
Reads zoned decimal data in which zeros have been left blank
Category: Numeric
See: ZDB w . d Informat in the documentation for your operating environment.
ZDB w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 0 “31
The ZDB w . d informat reads zoned decimal data that are produced in IBM 1410, 1401, and 1620 form, where 0s are left blank rather than being punched.
input @1 x zdb3.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F140C2 | 102 |
[*] The data line contains a hexadecimal representation of a binary number that is stored in zoned decimal form, including the codes for spaces, on an IBM mainframe operating environment. Each byte occupies one column of the input field. |
Reads and validates zoned decimal data
Category: Numeric
ZDV w . d
w
specifies the width of the input field.
Default: 1
Range: 1 “32
d
optionally specifies the power of 10 by which to divide the value.
Range: 1 “31
The ZDV w . d informat reads data in which every digit requires one byte and in which the last byte contains the value s sign along with the last digit. It also validates the input string and disallows invalid data.
ZDV w . d is dependent on the operating environment. For example, on IBM mainframes, ZDV w . d requires an F for all high-order nibbles except the last. (In contrast, the ZD w . d informat ignores the high-order nibbles for all bytes except those that are associated with the sign.) The last high-order nibble accepts values ranging from A-F, where A, C, E, and F are positive values and B and D are negative values. The low-order nibble on IBM mainframes must be a numeric digit that ranges from 0-9, as with ZD.
Note: Different operating environments store zoned decimal values in different ways. However, the ZDV w . d informat reads zoned decimal values with consistent results if the values are created in the same type of operating environment that you use to run SAS.
The ZDV w . d informat functions like the ZD w . d informat with one exception: ZDV w . d validates the input string and disallows invalid data.
input @1 test zdv4.;
When the Data Line [*] = ... | The Result is ... |
---|---|
----+----1 | |
F0F1F2C8 | 128 |
[*] The data line contains a hexadecimal representation of a binary number stored in zoned decimal form. The example was run on an IBM mainframe. The results may vary depending on your operating environment. |
Informats:
w . d Informat on page 1040
ZD w . d Informat on page 1046