Keeping zeros in SPSS to Con in ArcMap

3413
5
04-13-2012 10:06 AM
TheresaGoedeke
New Contributor
Hi,

I am working with 2010 Census block level data, specifically a geo2010 file from SF1, which is the Census geo-header file. I am manipulating this file in SPSS right now. However, SPSS stripped the zeros off of the values where the column width was wider than the existing value. For example, one county's code went from 003 to 3, even though the column width is still set to 3. I'm new to ArcMap, but I think that I need to get SPSS to keep these zeros in there or put them back in during export so that I can concatenate four variables in this dataset to make the required GeoID for my blocks...so that I can then join the Tiger Shapefile with the data table in ArcMap. Does anyone have suggestions?

Thanks,
Theresa
Tags (1)
0 Kudos
5 Replies
EricBowman
Occasional Contributor II
Hi,

I am working with 2010 Census block level data, specifically a geo2010 file from SF1, which is the Census geo-header file. I am manipulating this file in SPSS right now. However, SPSS stripped the zeros off of the values where the column width was wider than the existing value. For example, one county's code went from 003 to 3, even though the column width is still set to 3. I'm new to ArcMap, but I think that I need to get SPSS to keep these zeros in there or put them back in during export so that I can concatenate four variables in this dataset to make the required GeoID for my blocks...so that I can then join the Tiger Shapefile with the data table in ArcMap. Does anyone have suggestions?

Thanks,
Theresa


Hi Teresa,

I haven't worked with SPSS, but if you can finish your analysis there, export it out as a dbf or to a geodatabase table. I would then add that exported table to ArcMap.  Before you do any joins, you would need to fix the ID field from 1 to 001 for example.  If your ID field is in text to do the join to the shapefile, you are in luck.  In the newly added field, make sure it is a text field.  Use the field calculator on the new text field.  Make the expression <yournewfieldname> = "00"&[ID field].  This will append the 00 to 3.  If your field is a numeric field, may want to try formatting in the field properties.

Hope this helps.
Eric
0 Kudos
TerrySilveus
Occasional Contributor III
Hi Teresa,

I haven't worked with SPSS, but if you can finish your analysis there, export it out as a dbf or to a geodatabase table. I would then add that exported table to ArcMap.  Before you do any joins, you would need to fix the ID field from 1 to 001 for example.  If your ID field is in text to do the join to the shapefile, you are in luck.  In the newly added field, make sure it is a text field.  Use the field calculator on the new text field.  Make the expression <yournewfieldname> = "00"&[ID field].  This will append the 00 to 3.  If your field is a numeric field, may want to try formatting in the field properties.

Hope this helps.
Eric


however this would cause double digits to be incorrect changing "13" to "0013" when it might need to be "013" you can do this to fix the code given above.

<yournewfieldname> = right("00"&[ID field],3)
0 Kudos
JeffreyEvans
Occasional Contributor III
There could be variability in the number of leading zeros which would cause cross walk errors when joining your data. It is best of you deal with this issue in SPSS before exporting. You need to declare your ID field as a factor or character. Currently it is being treated as numeric and thus stripping off leading zeros.
0 Kudos
JonPeck1
New Contributor
Try assigning the variable a N format.  N format, which retains leading zeros in the display.  If that doesn't work, you can convert the variable to a string:
string z(A3).
compute z = string(x, N3).
0 Kudos
EricBowman
Occasional Contributor II
however this would cause double digits to be incorrect changing "13" to "0013" when it might need to be "013" you can do this to fix the code given above.

<yournewfieldname> = right("00"&[ID field],3)




Thanks Terry!  You are correct about the extra 0 for 13.  I was thinking of how to do this with python, but I'm not in the office this week to speak with my fellow instructor who writes our python courses.

Eric

P.S. I promoted your answer for you.
0 Kudos