BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SNG1
Calcite | Level 5

Hi

I have a data set which is addresses due to the data being messy, I need to remove the address that look like a number;

 

For Example -

 

101Crawfordstreet

200miltonave

10-101adamsways

123

10

0

105R

 

I have already compressed the address to remove any blanks, I need to remove 0 10 123 102R etc. anything that does not make any sense...is there a way to do that.

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

In addition to @kiranv_, I would add another condition.

 

data want;
set have;;
if anyalpha(address) = 0 or length(compress(address,,'ka'))<5   then delete;
run;

compress(address,,'ka') will keep only the alphabetic characters.

Likewise depending on your data you might add additional conditions that fits to your needs.

Thanks,
Suryakiran

View solution in original post

5 REPLIES 5
kiranv_
Rhodochrosite | Level 12

I think you should put more logic for address but below code will work for you

 
data have;
input address $30.;
datalines;
101Crawfordstreet
200miltonave
10-101adamsways
123
10
0
105R
;

data want;
set have;
if anyalpha(address) = 0 then delete;
run;
SuryaKiran
Meteorite | Level 14

In addition to @kiranv_, I would add another condition.

 

data want;
set have;;
if anyalpha(address) = 0 or length(compress(address,,'ka'))<5   then delete;
run;

compress(address,,'ka') will keep only the alphabetic characters.

Likewise depending on your data you might add additional conditions that fits to your needs.

Thanks,
Suryakiran
SNG1
Calcite | Level 5

Thanks Surya...your worked perfectly for my purpose much appreciated

Reeza
Super User

This article contains code that cleans up US addresses. I would suggest using it to parse the addresses. And any that don't parse as desired are deleted.

https://analytics.ncsu.edu/sesug/2008/CC-028.pdf

 


@SNG1 wrote:

Hi

I have a data set which is addresses due to the data being messy, I need to remove the address that look like a number;

 

For Example -

 

101Crawfordstreet

200miltonave

10-101adamsways

123

10

0

105R

 

I have already compressed the address to remove any blanks, I need to remove 0 10 123 102R etc. anything that does not make any sense...is there a way to do that.

 


 

SNG1
Calcite | Level 5

Thanks a Lot Everyone the solution provided worked from all by adding a few changes (i.e. filters) of my own...much appreciated.

 

Thanks!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1326 views
  • 2 likes
  • 4 in conversation