Skip to content

Using ArcView and ArcGIS With SAS, Stata and SPSS

It is posible to create, manipulate and analyze data in statistical software such as SAS, Stata and SPSS and use that data in ArcView and ArcGIS. There are a few steps and caveats, but the process is simple enough to make it worthwhile.

ArcView and ArcGIS store their data in DBase format, a fairly common filetype for databases. These types of files have and extension of .dbf, and can be read from and written to by SAS, Stata and SPSS (as well as Excel). Since each package has its own process, we'll discuss each one separately. We also assume that you have some basic knowledge of the packages described.

We strongly recommend that you copy all the necessary files to a new folder and work with the copies rather than the originals. This way, if you make a mistake, you can always go back to the beginning.

Using SAS with ArcView and ArcGIS

By using PROC IMPORT and PROC EXPORT, you can read and write .dbf files to use in ArcView and ArcGIS. The basic program is this:
  1. Reading a .dbf file into SAS. This step is needed only if you are reading a .dbf file into SAS.

    libname arc "C:\My Documents\arcview";
    proc import replace dbms=dbf
       datafile="C:\My Documents\arcview\counties.dbf"
       out=arc.InputSampleDBF;
    run;
    

    In the code above, the "replace" option refers to the SAS data file created by the "out=" option.

  2. Perform whatever analyses and/or data manipulations you want. Be sure to save the data when you are done.

  3. Write the SAS data you just created as a .dbf file to use in ArcView or ArcGIS. Here is the basic code:

    libname arc "C:\My Documents\arcview";
    proc export  replace dbms=dbf
       data=arc.OutputSampleDBF(keep=fips newvar)
       outfile="C:\My Documents\arcview\counties_new.dbf";
    run;
    
    Here the "replace" option refers to the .dbf file created in the "outfile" option. Keep only those variables in the SAS data file that you want to add to your map plus the one (and only one) variable you will use to join the tables in ArcView or ArcGIS. ArcView and ArcGIS will add will automatically add ALL of the variables in the file, so you may end up with alot of unnecessary or redundant information if you keep everything.
  4. Use the "join" feature in ArcView or ArcGIS to add the new data to your map.

Using Stata with ArcView and ArcGIS

Stata's "odbc" command can be used to read and write .dbf files. It's pretty simple:
  1. If necessary, read the .dbf file into Stata with this command:
    odbc load FIPS POP1990 POP1999, table("Counties") dsn("dBASE Files") lowercase
    
    This assumes, that you are already in the folder in which the file "Counties.dbf" can be found. This command will read the listed variables from the file "Counties.dbf" into memory. The "dsn("dBASE Files")" option simply tells Stata what kind of file it is. The "lowercase" option tells Stata to change all the variable names to lowercase (remember, Stata is case-sensistive!).
  2. Perform whatever analyses and/or manipulations you want. Be sure to save the data when you are done.
  3. Write the data out to a .dbf file:

    !del counties_new.dbf
    odbc insert fips popdiff , create table(counties_new) dsn("dBASE Files")
    

    This command writes the variables "fips" and "area" to the file "counties_new.dbf". You should write only those variables you want to add plus the one (and only one) you will use to join (merge) the tables in ArcView or ArcGIS.

    The "!del" command deletes the file named "counties_new.dbf" before it is re-created with the "odbc insert" command. This is necessary if you want to use the same file name. There is an "overwrite" option, but this only overwrites the variables, not the entire file. If you were to drop a variable and use the same file name with the "overwrite" option, the variable would remain in the file, but would have all missing values (it's as though you did "replace var1=." instead of "drop var1").

  4. Use the "join" feature in ArcView or ArcGIS to add the new data to your map.

Using SPSS with ArcView and ArcGIS

The "GET DATA" and "SAVE TRANSLATE" command in SPSS can be used to read and write .dbf files. Here are the basic steps:
  1. If necessary, read the data from a .dbf file:
    GET DATA 
             /TYPE=ODBC 
             /CONNECT='DSN=dBASE Files;'
             /SQL = 'SELECT  * FROM  `H:\MY DOCUMENTS\ARCVIEW`\`Counties` '.
    

    Pay very careful attention to the types and placement of the punctuation!!! The single quotes, accents, semicolons and period all must be in their proper places.

    This command reads all the the variables ("SELECT * ") from the file "Counties.dbf". You can read only specific variables, but the punctuation gets rather complicated, so it's easier to just read all of them.

  2. Perform whatever analyses or manipulations you want. Be sure to save the data when you are done.
  3. Write the data out to a new .dbf file:
    SAVE TRANSLATE OUTFILE='H:\My Documents\arcview\counties_new.dbf'
    	/TYPE=DB3
    	/replace
    	/KEEP= fips, popdiff .
    

    This command writes the variables "fips" and "popdiff" to the new file, "counties_new.dbf". Be sure to write only those variables you want to add and the one (and only one) variable you will use to join the tables in ArcView or ArcGIS.

    WARNING: If a variable's actual length is longer that what is specified in the "Variables" view of the data viewer, SPSS will round the values, and in some cases write missing values!!!" If this happens, SPSS will tell you there was a problem, but will still write the file.

  4. Use the "join" feature in ArcView or ArcGIS to add the new data to your map.

Using ArcView 3.3a With SAS, Stata and SPSS

After you have analyzed and manipulated your data in SAS, Stata or SPSS and written it to a .dbf file, you can then import this data into ArcView rather easily. We assume here, that you already have ArcView running and at least one layer displayed and active.
  1. Open the attribute table for the layer to which you want to add the new data. view
  2. Go to the Project window, click on "Tables," then "Add" to open the table you created with SAS, Stata or SPSS.view
  3. In the new table, click on the column you will use to match records to the attribute table.view
  4. In the attribute table, click on the column you will use to match records to the new table.view
  5. Go to the "Table" menu and select "Join."view
  6. If you find you need to edit the data you have joined, you will need to first remove the data you have already joined by selecting "Remove All Joins" from the "Table" menu.view

Using ArcGIS 9.0 With SAS, Stata and SPSS

After you have analyzed and manipulated your data in SAS, Stata or SPSS and written it to a .dbf file, you can then import this data into ArcView rather easily. We assume here, that you already have ArcView running and at least one layer displayed and active.
  1. Right click on the layer to which you would like to join the new data and select "Joins and Relates" and then "Join." view
  2. In the Join window, select "Join Attributes from a table," the field you want to use to join the two tables, the table with the new data you just created in SAS, Stata or SPSS, and again, select the field in the new table to use to join the tables. When you are done, click "OK." view
  3. ArcView will ask if you want to create an index. This is entirely optional and will not affect the results of the join. view
  4. To view the results of the join, you can right click on the layer and select "Open Attribute Table." The new data will be at the far right of the table. Note also that arcview will automatically add the table name to the field names. view
  5. If you need to edit the data you just joined in SAS, Stata or SPSS and re-join it, you will need to first remove the join you just performed. To do this, right click on the layer and select "Joins and Relates," then "Remove Joins," then the join you wish to remove. view
 
 
Syracuse University Logo area Library Banner