-1

I have a proc sql like this one, the problem is that sas remove the zero before each cust_comp_key for example FR_C_00000242 is transforming to 242 but i want to keep the zeo before 242 ...

rsubmit;
data ca_m_service_2; 
set ca_m_service;
num_compte = input(substr(CUST_COMP_KEY, 6),Best12.);
run;
endrsubmit;

Thanks for help

Edit,

I used this :

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);

It seems to work but now I need to transformr this vector to numeric, how can I do this ?

Mostafa90
  • 1,674
  • 1
  • 21
  • 39

1 Answers1

2

You can use z#. formats to pad numbers with leading zeros. Try:

num_compte = input(substr(CUST_COMP_KEY, 6),z8.);

Or this may be more intuitive:

data ca_m_service_2;
    set ca_m_service;
    format num_compte z8.;
    num_compte = substr(CUST_COMP_KEY, 6);
run;
Sean
  • 1,120
  • 1
  • 8
  • 14