07-05-2015 12:47 AM
I have a file (pobox_zip) that converts a city/PO box range to a new zip. This input file has ranges of PO boxes within each city, and each range is a separate record.
I have a second input fie that contains specific city/po box numbers and I want to match them to file 1 above by city/PO box and derive the new zip code.
The merge code below is not working. This is a many to many merge at the city code level.
merge pob (in=a) pobox_zip (in=b);
if a and b then do;
/* a and b means city code match....now look for a PO box range match*/
/* POB is PO box #; PO_from and PO_to are ranges of PO boxes*/
if pob >=PO_from and pob <= PO_to then do;
07-05-2015 04:01 PM
It would look like this:
create table data pobox_coded as
select a.*, b.zip5 as po_zip5
pob as a left join
pobox_zip as b
on a.city_code=b.city_code and
pob between PO_from and PO_to;
07-09-2015 11:23 PM
With a very minor adjustment the code worked.
Thanks for the tip.
I have used SAS in many to many merges, and it seems fine for match/append data. Strange that i does not work for range data.