BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8


There are some zip codes which have alphabets in them as shown below.I need to display only 08854 as the correct record.regular expressions does this job, but I figure the syntax.

00NSW

W85LJ

08854

3 REPLIES 3
Haikuo
Onyx | Level 15

DATA HAVE;

INPUT ZIPCODE $;

IF ANYALPHA(ZIPCODE) THEN DELETE;

CARDS;

00NSW

W85LJ

08854

;

Regards,

Haikuo

ballardw
Super User

Are the data by any chance multinational and you are getting other system postal codes? If so you may want to modifiy Haikuo's suggestion to output the data to two different datasets.


Doc_Duke
Rhodochrosite | Level 12

You can also use the sashelp.zipcode table to determine if any particular ZIP code is valid.  That data are updated every few months, so you may need to download the current one from sas.com.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 988 views
  • 0 likes
  • 4 in conversation