# Importing Public Data with SAS Instructions into R

- Author: DavidMSmith
- Published: 2012-07-12
- Canonical: https://www.smartdatacollective.com/importing-public-data-sas-instructions-r/

Many public agencies release data in a fixed-format ASCII (FWF) format. But with the data all packed together without separators, you need a "data dictionary" defining the column widths (and metadata about the variables) to make sense of them. Unfortunately, many agencies make such information available only as a SAS script, with the column information embedded in a PROC IMPORT statement.

To solve this problem, R user Anthony Damico (who's also the energetic voice behind the excellent [R Twotorials](http://www.twotorials.com/) series) created the SAScii package. It parses the SAS script (or even an unstructured text instructions file, with a PROC IMPORT statement included), and uses that information to read the associated fix-format ASCII file. Just provide the name or URL of the script/instructions file and the data file, and SAScii does the rest. There are several examples in the read.SAScii helpfile, including the R command to read the following public data sets:

- [2009 Medical Expenditure Panel Survey Emergency Room Visits File](http://meps.ahrq.gov/mepsweb/data_stats/download_data/pufs/h126e/h126esu.txt) ([Medical Expenditure Panel Survey](http://meps.ahrq.gov/mepsweb/index.jsp))

- [2010 National Health Interview Survey Persons file](ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/Program_Code/NHIS/2010/PERSONSX.sas) ([CDC](http://www.cdc.gov/nchs/data/factsheets/factsheet_nhis.htm))

- IPUMS - American Community Survey Extract ([Minnesota Population Center](http://www.ipums.org/))

- [2008 Survey of Income and Program Participation Wave 1](ftp://www.sipp.census.gov/pub/sipp/2008/l08puw1.sas) ([US Census](http://www.census.gov/apsd/techdoc/sipp/sipp.html))

Many thanks to Anthony for creating this package and pointing it out to me at the [useR!2102](http://blog.revolutionanalytics.com/2012/06/user-2012-highlights.html) conference last month. It unlocks many useful public data sets for those of us without SAS licenses.

SAScii package: read.SAScii documentation

