BookmarkSubscribeRSS Feed
ndovie
Calcite | Level 5

Hello, in the SAS Street Geocoding guide, it suggests removing extraneous information to improve street geocoding. I would like to remove the apartment or lot number at the end of the address string e.g., “1122 Main St Apt xxx” or “1122 Main St Lot xxx”, resulting in "1122 Main St"  to clean these data in preparation for street geocoding. I’m having difficulty with SAS code (below) to do this. Please advise? Thx!

 

data Test ; set Data1 (keep=address city zipcode state) ;
SUB = '<Apt>';
address = transtrn(STR,SUB,trimn(''));
run;

1 REPLY 1
SASKiwi
PROC Star
data want;
  street = "1122 Main St Apt xxx";
  street_cleaned = substr(street, 1, findw(upcase(street),'APT')-1);
  put _all_;
  street = "1122 Main St Lot xxx";
  street_cleaned = substr(street, 1, findw(upcase(street),'LOT')-1);
  put _all_;
run;

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
  • 1 reply
  • 578 views
  • 0 likes
  • 2 in conversation