cannot extract .dta.gz file

I cannot seem to extract a .dta.gz file and import it into R. The zipped file is about 100MB. Whether I unzip it using WinGZip and then import the actual .dta file into R, or try to unzip the whole file in R, I always end up getting an error that says ''not a Stata version 5-12 .dta file''.

Does anyone have any ideas about how to extract this file so that R will be able to read it?

Thanks!

The .dta files created by our extract system are formatted for Stata version 13. It appears the method you are using to import into R requires a .dta file intended for an older version of Stata. You might try the readstata13 package for R.

Hope this helps.

I have Stata 16 and I get the same error, what’s wrong?

IPUMS data are delivered as a compressed file (a Stata file would be *.dta.gz). You will need to decompress or unzip them before using them. I recommend 7zip as a free decompression software for Windows; the Archive Utility on a Mac will take care of this as well. Please let me know if decompressing the data file does not address this issue.

I’m having an issue unzipping a .dat.gz file on my Mac. The error I get is “Error 79 - Inappropriate file type or format”. This is a recent issue, I was able to unzip files from IPUMS a couple of months ago. I appreciate any suggestions.

Sorry for the inconvenience. Archive Utility sometimes struggles with certain gzipped files; I recommend using either The Unarchiver or using the gunzip command on your Mac Terminal (e.g., gunzip usa_00005.dat.gz). Please contact ipums@umn.edu if neither of these works for you so we can provide more targeted troubleshooting support.

Hello, I used the gunzip command, but the file unzipped appears to be a document rather than dataset. And it can’t be opened using Stata. What shall I do? Thank you!

By default, data are delivered as fixed-width text files (.dat extension). This file type can be read into Stata with the accompanying .do file delivered with your data extract (see screenshot below). Alternatively, you can request a data file that is formatted for Stata by clicking on the “Change” option in the Data Format row of your extract summary/definition page (see second screenshot).

Screenshot 1: Command file for reading fixed width data-set into Stata highlighted below.

Screenshot 2: Extract summary page change option for requesting a Stata-formatted data file.

1 Like

Thank you very much for the detailed solution Karl, it’s sorted!

1 Like