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.
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.
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;
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 Surya...your worked perfectly for my purpose much appreciated
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.
Thanks a Lot Everyone the solution provided worked from all by adding a few changes (i.e. filters) of my own...much appreciated.
Thanks!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.