art photo



I am unsure how to merge geographic data to a file that I have. I noticed that the census tract numbers do not stand alone in the data file that I downloaded from the census and that the GEO variable is saved as a text variable so I am unable to merge my data sets using that variable.

Would you be willing to show me how to link these two data sets if all I have is the census tract number?


Census tract numbers are only unique within a county. You need to create a unique id based on state, county, and census tract.

Thus, the following:

st   county  tract
26   113     60202

can be combined into a unique id:


This is done via this algorithm:

id = (st*1000000000) + (county*1000000) + tract;  

In your data, you may only have the census tract, but ideally you know the state and county as well. Otherwise, if your data are for a single county within a state, you can just use the tract portion of the GEO_ID2 variable. If you save the item as 'text' it is in fixed format with state in the first two columns, county in the next three columns, and tract in the last 6 columns. Thus, you could read:

input junk 1-5 and tract as 6-11;

Related Question Groups: