Editing numeric fields
Suppose you have input records with numeric values stored in PD format that you want to display or print so they can be easily interpreted. PD values are stored as integers in a compressed internal format that is actually unreadable if you print or display the values.
- The first PD field represents a number with two decimal places.
- The second PD field represents a number with three decimal places.
- The third PD field represents a date in the form mmddyyyy.
You can use the edit features of the OUTREC statement to display the digits of the PD values as readable characters. Furthermore, you can use the edit features to insert signs, commas, decimal points and hyphens, as appropriate, to make the PD values easy to interpret.
CH field | First PD field | Second PD field | Third PD field |
---|---|---|---|
1 8
|
11 16
|
31 37
|
41 45
|
WEST
EAST NORTH SOUTH |
+1524900810
-0065781053 +0000000000 -0000003562 |
+0000000020000
+0721500532006 -0000982630735 -0003826254999 |
+05122003
+11292003 +02152004 +12032003 |
OUTREC FIELDS=(1,8,
5X,
11,6,PD,M4,
5X,
31,7,PD,EDIT=(SI,III,III,IIT.TTT),SIGNS=(,-),
5X,
41,5,PD,EDIT=(TT-TT-TTTT))
- I indicates a leading insignificant digit to be displayed as 1-9, or as blank for a leading 0.
- T indicates a significant digit to be displayed as 0-9.
- S before the digits indicates a leading sign. S after the digits indicates a trailing sign. For M4, the leading sign is to be displayed as + for a positive value or as - for a negative value. For EDIT=(SI,III,III,IIT.TTT),SIGNS=(,-), the leading sign is to be displayed as blank for a positive value or as - for a negative value.
- Any other character (for example, comma, decimal point or hyphen) is just displayed as appropriate.
WEST +15,249,008.10 20.000 05-12-2003
EAST -657,810.53 3,721,500,532.006 11-29-2003
NORTH +0.00 -982,630.735 02-15-2004
SOUTH -35.62 -3,826,254.999 12-03-2003
Pre-defined and user-defined edit masks give you a great deal of flexibility in how you format your numeric fields for output. You can use p,m,f,Mnn or p,m,f,EDIT=(pattern) to edit various numeric fields according to various output patterns. You can use SIGNS=(a,b,c,d) to override or set the output signs (leading positive, leading negative, trailing positive and trailing negative). You can use LENGTH=n to override or set the output length.
Mask | Pattern | Examples | |
---|---|---|---|
Value | Result | ||
M0 | IIIIIIIIIIIIIIIIIIIIIIIIIIIIIITS | +01234 | 1234 |
-00001 | 1- | ||
M1 | TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTS | -00123 | 00123- |
+00123 | 00123 | ||
M2 | II,III,III,III,III,III,III,III,III,IIT.TTS | +123450 | 1,234.50 |
-000020 | 0.20- | ||
M3 | II,III,III,III,III,III,III,III,III,IIT.TTCR | -001234 | 12.34CR |
+123456 | 1,234.56 | ||
M4 | SII,III,III,III,III,III,III,III,III,IIT.TT | +0123456 | +1,234.56 |
-1234567 | -12,345.67 | ||
M5 | SII,III,III,III,III,III,III,III,III,IIT.TTS | -001234 | (12.34) |
+123450 | 1,234.50 | ||
M6 | III-TTT-TTTT | 00123456 | 012-3456 |
12345678 | 1-234-56788 | ||
M7 | TTT-TT-TTTT | 00123456 | 000-12-3456 |
12345678 | 012-34-5678 | ||
M8 | IT:TT:TT | 030553 | 3:05:53 |
121736 | 12:17:36 | ||
M9 | IT/TT/TT | 123004 | 12/30/04 |
083104 | 8/31/04 | ||
M10 | IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIT | 01234 | 1234 |
00000 | 0 | ||
M11 | TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT | 00010 | 00010 |
01234 | 01234 | ||
M12 | SI,III,III,III,III,III,III,III,III,III,IIT | +1234567 | 1,234,567 |
-0012345 | -12,345 | ||
M13 | SI.III.III.III.III.III.III.III.III.III.IIT | +1234567 | 1.234.567 |
-0012345 | -12.345 | ||
M14 | SI III III III III III III III III III IITS | +1234567 | 1 234 567 |
-0012345 | (12 345) | ||
M15 | I III III III III III III III III III IITS | +1234567 | 1 234 567 |
-0012345 | 12 345- | ||
M16 | SI III III III III III III III III III IIT | +1234567 | 1 234 567 |
-0012345 | -12 345 | ||
M17 | SI'III'III'III'III'III'III'III'III'III'IIT | +1234567 | 1'234'567 |
-0012345 | -12'345 | ||
M18 | SII,III,III,III,III,III,III,III,III,IIT.TT | +0123456 | 1,234.56 |
-1234567 | -12,345.67 | ||
M19 | SII.III.III.III.III.III.III.III.III.IIT,TT | +0123456 | 1.234,56 |
-1234567 | -12.345,67 | ||
M20 | SI III III III III III III III III IIT,TTS | +0123456 | 1 234,56 |
-1234567 | (12 345,67) | ||
M21 | II III III III III III III III III IIT,TTS | +0123456 | 1 234,567 |
-1234567 | 12 345,67- | ||
M22 | SI III III III III IIII III III III IIT,TT | +0123456 | 1 234,56 |
-1234567 | -12 345,67 | ||
M23 | SII'III'III'III'III'III'III'III'III'IIT.TT | +0123456 | 1'234.56 |
-1234567 | -12'345.67 | ||
M24 | SII'III'III'III'III'III'III'III'III'IIT,TT | +0123456 | 1'234,56 |
-1234567 | -12'345,67 | ||
M25 | SIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIT | +01234 | 1234 |
-00001 | -1 | ||
M26 | STTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT | 1234 | +01234 |
-1 | -00001 |