TRANTAB Procedure

Example 3: Editing by Specifying a Decimal Value for Starting Position

Features:

LIST statement

REPLACE statement

SAVE statement

This example edits the translation table that was created in Creating a Translation Table. The decimal value specified in the REPLACE statement marks the starting position for the changes to the table.
The vertical arrow in both SAS logs marks the point at which the changes begin.
All examples were produced in the UNIX environment.

Program 1: Display the Original Table

options nodate pageno=1 linesize=80 pagesize=60; proc trantab table=newtable; 
list one;

Program Description

Set the system options and specify the translation table to edit.
options nodate pageno=1 linesize=80 pagesize=60; proc trantab table=newtable; 
Display the original table. This LIST statement displays the original NEWTABLE translation table.
list one;

SAS Log

The Original NEWTABLE Translation Table
Table specified is NEWTABLE.
NOTE: NEWTABLE table 2 is uninitialized.
NEWTABLE table 1:
                             ↓
          0 1 2 3 4 5 6 7 8 9 A B C D E F
     00 '00010203A309E57FF9ECC40B0C0D0E0F'x
     10 '10111213A5E008E71819C6C51C1D1E1F'x
     20 'C7FCE9E2E40A171BEAEBE8EFEE050607'x
     30 'C9E616F4F6F2FB04FFD6DCA2B6A7501A'x
     40 '20E1EDF3FAF1D1AABABFA22E3C282B7C'x
     50 '265FACBDBCA1ABBB5F5F21242A293BAC'x
     60 '2D2F5FA6A6A6A62B2BA6A62C255F3E3F'x
     70 'A62B2B2B2B2B2B2D2D603A2340273D22'x
     80 '2B6162636465666768692D2BA6A62B2B'x
     90 '2D6A6B6C6D6E6F7071722DA62D2B2D2D'x
     A0 '2D7E737475767778787A2D2B2B2B2B2B'x
     B0 '2B2B2B5F5FA65F5F5FDF5FB65F5FB55F'x
     C0 '7B4142434445464748495F5F5F5F5F5F'x
     D0 '7D4A4B4C4D4E4F5051525F5F5FB15F5F'x
     E0 '5C83535455565758595A5F5FF75F5FB0'x
     F0 '30313233343536373839B75F6EB25F5F'x

Program 2: Edit the Table

replace 10
   20 10 200 'x' 'ux' '092040'x;
save;
 list one;

Program Description

Replace characters in the translation table, starting at a specified position. The REPLACE statement starts at position decimal 10, which is byte 11 in the original table, and performs a byte-to-byte replacement with the given values.
replace 10
   20 10 200 'x' 'ux' '092040'x;
Save the changes. The SAVE statement saves the changes that you made to the NEWTABLE translation table.
save;
Display the new table. The second LIST statement displays the edited NEWTABLE translation table.
 list one;

SAS Log

Saving table NEWTABLE.
NOTE: NEWTABLE table 2 will not be saved because it is uninitialized.
NEWTABLE table 1:
                             ↓
          0 1 2 3 4 5 6 7 8 9 A B C D E F
     00 '00010203A309E57FF9EC140AC8787578'x
     10 '09204013A5E008E71819C6C51C1D1E1F'x
     20 'C7FCE9E2E40A171BEAEBE8EFEE050607'x
     30 'C9E616F4F6F2FB04FFD6DCA2B6A7501A'x
     40 '20E1EDF3FAF1D1AABABFA22E3C282B7C'x
     50 '265FACBDBCA1ABBB5F5F21242A293BAC'x
     60 '2D2F5FA6A6A6A62B2BA6A62C255F3E3F'x
     70 'A62B2B2B2B2B2B2D2D603A2340273D22'x
     80 '2B6162636465666768692D2BA6A62B2B'x
     90 '2D6A6B6C6D6E6F7071722DA62D2B2D2D'x
     A0 '2D7E737475767778787A2D2B2B2B2B2B'x
     B0 '2B2B2B5F5FA65F5F5FDF5FB65F5FB55F'x
     C0 '7B4142434445464748495F5F5F5F5F5F'x
     D0 '7D4A4B4C4D4E4F5051525F5F5FB15F5F'x
     E0 '5C83535455565758595A5F5FF75F5FB0'x
     F0 '30313233343536373839B75F6EB25F5F'x

Output Details

At position 10 (which is byte 11), a vertical arrow denotes the starting point for the changes to the translation table.
At byte 11, decimal 20 (which is hexadecimal 14) replaces hexadecimal C4.
At byte 12, decimal 10 (which is hexadecimal 0A) replaces hexadecimal 0B.
At byte 13, decimal 200 (which is hexadecimal C8) replaces hexadecimal 0C.
At byte 14, character 'x' (which is hexadecimal 78) replaces hexadecimal 0D.
At bytes 15 and 16, characters 'ux' (which are hexadecimal 75 and 78, respectively) replace hexadecimal 0E and 0F.
At bytes 17, 18, and 19, hexadecimal 092040 replaces hexadecimal 101112.