How to: |
The ATODBL function converts a number in alphanumeric format to decimal (double-precision) format.
ATODBL(source_string, length, output)
where:
Is the string consisting of digits and, optionally, one sign and one decimal point to be converted, or a field or variable that contains the string.
Is the two-character length of the source string in bytes. This can be a numeric constant, or a field or variable that contains the value. If you specify a numeric constant, enclose it in single quotation marks, for example '12'.
Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.
ATODBL converts the EMP_ID field into double-precision format and stores the result in D_EMP_ID:
TABLE FILE EMPLOYEE PRINT LAST_NAME AND FIRST_NAME AND EMP_ID AND COMPUTE D_EMP_ID/D12.2 = ATODBL(EMP_ID, '09', D_EMP_ID); WHERE DEPARTMENT EQ 'MIS'; END
The output is:
LAST_NAME FIRST_NAME EMP_ID D_EMP_ID --------- ---------- ------ -------- SMITH MARY 112847612 112,847,612.00 JONES DIANE 117593129 117,593,129.00 MCCOY JOHN 219984371 219,984,371.00 BLACKWOOD ROSEMARIE 326179357 326,179,357.00 GREENSPAN MARY 543729165 543,729,165.00 CROSS BARBARA 818692173 818,692,173.00
In the following example, the Master File contains the MISSING attribute for the CURR_SAL field. If you do not enter a value for this field, it is interpreted as the default value, a period.
FILENAME=EMPLOYEE, SUFFIX=FOC SEGNAME=EMPINFO, SEGTYPE=S1 FIELDNAME=EMP_ID, ALIAS=EID,FORMAT=A9, $ . . . FIELDNAME=CURR_SAL, ALIAS=CSAL,FORMAT=D12.2M, MISSING=ON,$ . . .
ATODBL converts the value supplied for TCSAL to double-precision format:
MODIFY FILE EMPLOYEE COMPUTE TCSAL/A12=; PROMPT EID MATCH EID ON NOMATCH REJECT ON MATCH TYPE "EMPLOYEE <D.LAST_NAME <D.FIRST_NAME" ON MATCH TYPE "ENTER CURRENT SALARY OR 'N/A' IF NOT AVAILABLE" ON MATCH PROMPT TCSAL ON MATCH COMPUTE CSAL MISSING ON = IF TCSAL EQ 'N/A' THEN MISSING ELSE ATODBL(TCSAL, '12', 'D12.2'); ON MATCH TYPE "SALARY NOW <CSAL" DATA
A sample execution is:
EMPLOYEE ON 11/14/96 AT 13.42.55 DATA FOR TRANSACTION 1 EMP_ID = 071382660 EMPLOYEE STEVENS ALFRED ENTER CURRENT SALARY OR 'N/A' IF NOT AVAILABLE TCSAL = N/A SALARY NOW . DATA FOR TRANSACTION 2 EMP_ID = 112847612 EMPLOYEE SMITH MARY ENTER CURRENT SALARY OR 'N/A' IF NOT AVAILABLE TCSAL = 45000 SALARY NOW $45,000.00 DATA FOR TRANSACTION 3 EMP_ID = end TRANSACTIONS: TOTAL = 2 ACCEPTED= 2 REJECTED= 0 SEGMENTS: INPUT = 0 UPDATED = 0 DELETED = 0
The procedure processes as follows: