I have phone number data in which the three “parts” of the phone number were originally stored as separate numeric variables so that any leading zeroes were dropped (e.g., “014” became 14 and “004” became 4. So a phone number of 004-017-0123 is now shown as 4-17-123.)
How can I re-seperate the numbers and re-add the dropped zeros?
In a DATA step, use the SCAN function to split the data-string into three, and also use the PUT(,Z3.) for example. And use CATX to rebuild the number from the components.
Thanks Scott, almost there. When I use CATX to reform the phone numbers after splitting and adding the zeros, CATX drops off the zeros I added. Any ideas? My current code is below. Thanks.
Phone_Number=Translate(Phone_Number,'---','._/');
format Phone1 Phone2 z3. Phone3 z4.;
Phone1=scan(Phone_Number,1);
Phone2=scan(Phone_Number,2);
Phone3=scan(Phone_Number,3);