First, if possible provide the starting data in the form of data step code as shown below.
Second paste the code in a text box as sometimes code pasted into the main message windows will not run because of reformatting done by the forum software.
This works for your example data:
data have;
infile datalines truncover;
input zip_code_have $30.;
datalines4;
916
37322
3452
5701-4012
98682
12953
46311
1234; 1234; 23456-4444
84032; 84095; 84065; 84065
;;;;
data want;
set have;
/* need to define a length for the zip_code_want
long enough to hold multiple inserted characters
such as missing leading 0 plus the delimiters
*/
length zip_code_want $ 50 z_temp $ 10.;
/* get number of zip codes in file*/
do i=1 to countw(zip_code_have,';');
/* get ONE zip*/
z_temp=scan(zip_code_have,i,';');
if index(z_temp,'-')>0 then z_temp=scan(z_temp,1,'-');
z_temp =put(input(strip(z_temp),5.),z5.);
zip_code_want=catx('; ',zip_code_want,z_temp);
end;
drop z_temp i;
run;