我有一个这样的proc sql,问题是sas在每个cust_comp_key之前删除零,例如FR_C_00000242正在转换为242但是我想在242之前保留zeo ...
rsubmit;
data ca_m_service_2;
set ca_m_service;
num_compte = input(substr(CUST_COMP_KEY, 6),Best12.);
run;
endrsubmit;
感谢您的帮助
编辑,
我用过这个:
data ca_m_service_3;
set ca_m_service;
if length(substr(CUST_COMP_KEY, 6)) >= 8 then newsic=substr(CUST_COMP_KEY, 6);
else newsic=repeat('0',8-length(substr(CUST_COMP_KEY, 6))-1)||substr(CUST_COMP_KEY, 6);
它似乎有效但现在我需要将此向量转换为数字,我该怎么做?
答案 0 :(得分:2)
您可以使用z#。格式用于填充带前导零的数字。尝试:
num_compte = input(substr(CUST_COMP_KEY, 6),z8.);
或者这可能更直观:
data ca_m_service_2;
set ca_m_service;
format num_compte z8.;
num_compte = substr(CUST_COMP_KEY, 6);
run;