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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 332 views
  • 0 likes
  • 2 in conversation