EconPapers    
Economics at your fingertips  
 

Optimizing Stata for Analysis of Large Data Sets

Joseph Canner () and Eric Schneider
Additional contact information
Joseph Canner: Johns Hopkins University School of Medicine
Eric Schneider: Johns Hopkins School of Medicine

2013 Stata Conference from Stata Users Group

Abstract: As with most programming languages, there can be multiple ways to do a task in Stata. Using modern CPUs with adequate memory, most Stata data processing commands run so quickly on small- or moderate-sized data sets that it is impossible to tell whether one command performs more efficiently than another. However, when analyzing large data sets such as the Nationwide Inpatient Sample (NIS), with about 8 million records per year (~3.5GB), this choice can make a substantial difference in performance. Using the Stata timer command, we performed standardized benchmarks of common programming tasks, such as searching the NIS for a list of ICD-9 codes, converting string data to numeric, and putting numeric variables in categories. For example, the inlist function can achieve significant performance gains compared to the equivalent “var==exp1 | var==exp2” notation (38% improvement) or using foreach loops (300% improvement). Using the real and subinstr functions to remove characters from strings and convert them to numbers is about 20 times faster than the destring command. The inlist, inrange, and recode functions also perform considerably better than the equivalent recode commands (13-70 times faster), especially for string variables, and are often easier to write and to read.

Date: 2013-08-01
References: Add references at CitEc
Citations:

Downloads: (external link)
http://repec.org/norl13/canner.pptx (application/x-ms-powerpoint)

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:boc:norl13:10

Access Statistics for this paper

More papers in 2013 Stata Conference from Stata Users Group Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().

 
Page updated 2025-03-19
Handle: RePEc:boc:norl13:10