Reputation: 17
I am trying to convert a string into numeric and used the following code
select
PROC SQL;
CREATE TABLE WORK.CLAIM_HISTORY AS
SELECT input(cats(substr(SUBSTR(t1.LIABILITY_CTRT_ID,3),1,length(SUBSTR(t1.LIABILITY_CTRT_ID,3))-6),substr(t1.LIABILITY_CTRT_ID,13)),Z10.) AS GENERAL_INSURANCE_UOE_RK,
t1.UNDERWRITING_DT
FROM work.SIN t1
LEFT JOIN work.custos_agregados_liab t2 ON (t1.CLAIM_NO = t2.CLAIM_NO)
where t2.COVERAGE_CD <> '999';
QUIT;
when for example, GENERAL_INSURANCE_UOE_RK wass 0223963 and when using the input functions, sas is deleting the leading zero and returning 223963. I would like to have exactly the same number, just formatted as number.
Thanks in advance.
Upvotes: 0
Views: 1106
Reputation: 51566
Leading zeros have no meaning on a numeric value. But you can attach the Z format to a numeric variable and have SAS display the value with leading zeros.
Note there is another error in your code as you are trying to use Z10.
as an INFORMAT
. There is no Z
informat. Just use the normal numeric informat to convert the string into a number.
select
input(cats(substr(SUBSTR(t1.LIABILITY_CTRT_ID,3),1,length(t1.LIABILITY_CTRT_ID)-8)
,substr(t1.LIABILITY_CTRT_ID,13)
)
,32.) AS GENERAL_INSURANCE_UOE_RK format=Z10.
,t1.UNDERWRITING_DT
Upvotes: 2