DOI: 10.7910/dvn/bgp8eb
title: Basic Stand Alone Medicare Claims Public Use Files (BSAPUFs)

description: &lt;h3 class="post-title entry-title" itemprop="name"&gt; analyze the basic stand alone medicare claims public use files (bsapufs) with r and monetdb &lt;/h3&gt; the centers for medicare and medicaid services (cms) took the plunge. the famous &lt;a href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2748070/"&gt;medicare 5% sample&lt;/a&gt; has been &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/index.html"&gt;released to the public, free of charge&lt;/a&gt;. jfyi - &lt;a href=
"http://en.wikipedia.org/wiki/Medicare_%28United_States%29"&gt;medicare
&lt;/a&gt; is the u.s. government program that provides health insurance to 50 million elderly and disabled americans. the basic stand alone medicare claims public use files (bsapufs) contain either person- or event-level data on &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Inpatient_Claims.html"&gt;inpatient stays&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/BSA_DME_Line_Items_PUF.htm
l"&gt;durable medical equipment purchases&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/BSA_PDE_PUF.html"&gt;prescription drug fills&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Hospice_Bene.html"&gt;hospice users&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Carrier_Line_Items.html"&gt;doctor visits&lt;/a&gt;, &lt;a href="http://ww
w.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/HHA_PUF.html"&gt;home health provision
&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Outpatient_Proc.html"&gt;outpatient hospital procedures&lt;/a&gt;, &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/SNF_Bene_PUF.html"&gt;skilled nursing facility short-term residents&lt;/a&gt;, as well as aggregated statistics for &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Chronic_Conditions_P
UF.html"&gt;medicare beneficiaries with chronic conditions&lt;/a&gt; and &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/IPBS_PUF.html"&gt;medicare beneficiaries living in nursing homes&lt;/a&gt;. oh sorry, there's one catch: they only provide sas scripts to analyze everything. cue the villian music. that bored old game of monopoly ends today.&lt;br /&gt; &lt;br /&gt; the initial release of the 2008 bsapufs was accompanied by &lt;a href="http://academyhealth.org/Training/Re
sourceDetail.cfm?itemnumber=7097"&gt;some major fanfare in the world of health policy
&lt;/a&gt;, a big win for government transparency. unfortunately, the final files that cleared the confidentiality hurdles are heavily de-identified and &lt;a href="http://en.wikipedia.org/wiki/Obfuscation_%28software%29"&gt;obfuscated&lt;/a&gt;. prime examples:&lt;br /&gt; &lt;ul&gt; &lt;li&gt;none of the files can be linked to any other file. not across years, not across expenditure categories&lt;/li&gt; &lt;li&gt;costs are rounded to the nearest fifth or tenth dollar at lower values, nearest thousandth at higher values&lt;/li&gt; &lt;li&gt;ages
are categorized into five year bands&lt;/li&gt; &lt;/ul&gt; so these files are baldly inferior to the unsquelched, linkable data only available through &lt;a href="http://www.resdac.org/cms-data/request/research-identifiable-files"&gt;an expensive formal application process&lt;/a&gt;. any researcher with a budget flush enough to afford a sas license (the only statistical software mentioned in &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/Downloads/2008_BSA_Carrie
r_Line_Items_PUF_DUG.zip"&gt;the cms official documentation&lt;/a&gt;) can probably also cough up the money to buy the identifiable data through &lt;a href="http://resdac.org/"&gt;resdac&lt;/a&gt; (resdac, btw, rocks).&lt;br /&gt; &lt;br /&gt; soapbox:&lt;br /&gt; &lt;br /&gt; cms released free public data sets that could only be analyzed with &lt;a href="https://www.google.com/search?q=how+much+does+sas+cost"&gt;a software package costing thousands of dollars&lt;/a&gt;. so even though the actual data sets were free, researchers still needed deep pock
ets to buy &lt;a href="http://sas.com/"&gt;sas&lt;/a&gt;. meanwhile, the un&lt;a href="http://en.wikipedia.org/wiki/Obfuscation_%28software%29"&gt;squelched&lt;/a&gt; and therefore superior data sets are also available for many thousands of dollars. researchers with funding would (reasonably) just buy the better data. researchers without any financial resources - the target audience of free, public data - were left out in the cold. no wonder these bsapufs haven't been used much.&lt;br /&gt; &lt;br /&gt; that ends now. using r, &lt;a
href="http://monetdb.org/"&gt;monetdb&lt;/a&gt;, and the personal computer you already own (mine cost $700 in 2009), researchers can, for the first time, seriously analyze these medicare public use files without spending another dime. woah. plus hey guess what all you researcher fat-cats with your federal grant streams and your proprietary software licenses: r + monetdb runs one heckuva lot faster than sas. woah^2. dump your sas license water wings and learn how to swim. the scripts below require monetdb
. &lt;a href="https://github.com/ajdamico/usgsd/blob/master/MonetDB/monetdb%20installation%20instructions.R"&gt;click here for step-by-step instructions of how to install it on windows&lt;/a&gt; and &lt;a href="http://www.asdfree.com/2013/03/column-store-r-or-how-i-learned-to-stop.html"&gt;click here for speed tests&lt;/a&gt;. vroom.&lt;br /&gt; &lt;br /&gt; since the bsapufs comprise 5% of the medicare population, ya generally need to multiply any counts or sums by twenty. although the individuals represented in these claims are
randomly sampled, this data should not be treated like a &lt;a href="http://www.jstatsoft.org/v09/a08/paper"&gt;complex survey sample&lt;/a&gt;, meaning that the creation of a &lt;a href="http://faculty.washington.edu/tlumley/survey/html/svydesign.html"&gt;survey object&lt;/a&gt; is unnecessary. most bsapufs generalize to either the total or &lt;a href="http://en.wikipedia.org/wiki/Fee-for-service"&gt;fee-for-service&lt;/a&gt; medicare population, but each file is different so give the documentation a hard stare before that eureka
moment. this new github repository contains three scripts:&lt;br /&gt; &lt;br /&gt; &lt;b&gt;2008 - download all csv files.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;loop through and download every zip file hosted by cms&lt;/li&gt; &lt;li&gt;&lt;a href="http://stat.ethz.ch/R-manual/R-devel/library/utils/html/unzip.html"&gt;unzip&lt;/a&gt; the contents of each zipped file to the working directory&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;2008 - import all csv files into monetdb.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;create the batch (.bat) file needed to initiate the monet database in the f
uture&lt;/li&gt; &lt;li&gt;loop through each csv file in the current working directory and import them into the monet database&lt;/li&gt; &lt;li&gt;create a well-documented block of code to re-initiate the monetdb server in the future&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;b&gt;2008 - replicate cms publications.R&lt;/b&gt;&lt;br /&gt; &lt;ul&gt; &lt;li&gt;initiate the same monetdb server instance, unsing the same well-documented block of code as above&lt;/li&gt; &lt;li&gt;replicate nine sets of statistics found in data tables provided by cms &lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; &lt;br /&gt; &lt;
a href="https://github.com/ajdamico/usgsd/tree/master/Basic%20Stand%20Alone%20Medicare%20Claims%20Public%20Use%20Files"&gt;click here to view these three scripts
&lt;/a&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; for more detail about the basic stand alone medicare claims public use files (bsapufs), visit:&lt;br /&gt; &lt;ul&gt; &lt;li&gt;the centers for medicare and medicaid's bsapuf &lt;a href="http://www.cms.gov/Research-Statistics-Data-and-Systems/Statistics-Trends-and-Reports/BSAPUFS/index.html"&gt;homepage&lt;/a&gt;&lt;/li&gt; &lt;li&gt;a joint &lt;a href="http://academyhealth.org/Training/ResourceDetail.cfm?itemnumber=7097"&gt;academyhealth webinar&lt;/a&gt; given by the organizations that partnered to create these files
- &lt;a href="http://cms.gov/"&gt;cms&lt;/a&gt;, &lt;a href="http://www.impaqint.com/"&gt;impaq&lt;/a&gt;, &lt;a href="http://www.norc.org/"&gt;norc&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;br /&gt; notes:&lt;br /&gt; &lt;br /&gt; the replication script has oodles of easily-modified syntax and should be viewed for analysis examples. if you know the name of the data table you want to examine, you can quickly modify &lt;a href="https://github.com/ajdamico/usgsd/blob/master/MonetDB/monetdb%20database%20accessing%20instructions.R"&gt;these general monetdb analysis examples
&lt;/a&gt; too. just run sql queries - sas users, that's "proc sql;" for you. never used sql? start fresh with &lt;a href="http://www.w3schools.com/sql/default.asp"&gt;this tutorial&lt;/a&gt;. once you know the sql command you want to run on the data, you're almost done. for operations that make changes to the data tables, use dbSendUpdate(). for operations that only read the data tables, use dbGetQuery().&lt;br /&gt; &lt;br /&gt; don't ever use dbReadTable() on the outpatient, carrier, dme, or prescription drug event tables
- they'll likely cause r to crash.&lt;br /&gt; &lt;br /&gt; if you need the more advanced statistical functions described on &lt;a href="http://sqlsurvey.r-forge.r-project.org/"&gt;the sqlsurvey homepage&lt;/a&gt; but not available in monetdb's flavor of sql, you could potentially create a taylor-series sqlsurvey() object with a weight column full of twenties and a strata+psu column with all ones. the statistics should be correct, but if the columns in your analysis include any missing data, the variances might be wid
er (so more conservative) than those computed with monetdb's stddev() function.
&lt;br /&gt; &lt;br /&gt; confidential to sas, spss, stata, and sudaan users: why are you using software that's twenty years shy of medicare eligibility itself? time to transition to r. :D