BookmarkSubscribeRSS Feed
ioannis
Fluorite | Level 6

Hello,

 

I have a dataset with the following three variables:  branch_address, X, Y

 

X and Y refer to the coordinates for a company's branch. I want to convert the coordinates to census tracts. I have already downloaded the lookup files from SAS (USM, USP, and USS) and have managed to convert the address to census tracts. However, some addresses have misspelled words and cannot be matched. Using coordinates to find the tract seems more appropriate. Is there a way I can do this in SAS? The code I used to match branch address to census tract is below. Is there a way I can modify it using coordinates from the input file? For the record, the three lookup files SAS I downloaded from here (https://support.sas.com/rnd/datavisualization/mapsonline/html/geocode.html)

 

Thanks a bunch in advance!

 

CODE:

 

proc geocode
method=street 
lookupstreet=lookup.usm 
lookupcity=sashelp.zipcode 
data=input_data
addressvar=address 
attributevar=(tract, block) 
out=output_data; 
run;

2 REPLIES 2
noling
SAS Employee

Edit: Looks like this has been asked before and if you have a shape file reference, you can start here.

 

Hi ioannis, I just looked into proc geocode for the first time and from what I can tell there's no lat/long -> census tract conversion. It sounds like you've already had some success using addresses. How many addresses have misspellings? If it's a small number, you might consider just manually correcting them. Garbage in Garbage out.

 

I was going to suggest that map your zip codes to census blocks, but it looks like "The boundaries of ZIP Codes and census tracts often don't match"

 

If you can't correct your data you could brute force it and calculate the difference between your lat/lon's and the nearest lat/lon with a census tract, and assume the nearest census tract is also your record's census tract. Of course this estimation may cross a census tract boundary and give you an incorrect answer. Only do this for your misspelled records since you already have a working solution for your other data.

 

In short, first try to correct your data! 


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

IsaacYi881
Calcite | Level 5

I am currently in the same boat. I have a data set with address (by street, city, state, zip) along with longitude and latitude coordinates. I can match most of the address but having rows over 5000+ I am getting around 600 rows that are unmatched. 

 

I believe there are online programs that can convert addresses to census tracts in batches but even then I still get unmatched locations. Looking into details of the addresses that do not match through google, there doesn't seem to be any typos or reasons why it was unmatched unless the addresses are brand new and the lookup.USM map is outdated? 

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
  • 2 replies
  • 4294 views
  • 0 likes
  • 3 in conversation