How to check for a valid zip code when you have a large list of valid zips
The attached spec ZIPCODE.QPXis one way to check for a valid zip code when you have a large list of valid zips (thousands). Use a Disk-Based Recode table with a Catch-All category to check for validity.
This example builds a Disk-Based Recode Table with 5000 entries in it, so it takes a while to compile it. You can change the Repeat to create lessentries for faster testing.
>PURGESAME~PREP COMPILE -SPECS[ZipCode]{Zipcodes: .5Enter in zipcodeTo test a good zip code type: 03007To test a bad zip code type: 55007!Var,N,5,5 }{Ziptest: [Zipcodes]!Fld,A,,zipcode.dbr }{!Goto, Good }{Badzip::Zipcodes: is not one of the valid zips!!!!! Try Again.!Reset, Zipcodes }{Good:This is good!Display }~CommentThis part builds the Disk-Based Recode Table. The Nested Repeat is just used to build a fairly large list of items (5000). Your file would just be a list that had the zipcode left justified, followed by one or more spaces, followed by the zip code again. See the few items at the end of the list after then nested repeat for an example.The last item in the list wants to be all ????? with a skipto on it of Skipto BadZip. This will cause unmatched items to skip to that question. All valid answers will just fall through to the next question.~PREP DBROUTPUT=zipcode.dbr,ENTRIES=20000>REPEAT $A=001,...,100>REPEAT $Z=01,03,...,99$A$Z $A$Z>ENDREP>ENDREP''Your actual file will look more like the following lines, for as many as''you need.20099 2009930099 3009940099 4009950099 50099????? (Skipto BadZip) ?????END~END