The Social Security Administration makes available their annual name data going back to 1880 here. It’s fun data to play with. Phil Cohen has done some cool things with it here and here.

But it comes as 136 *.txt files — one of each year! As a very small public service, I wrote some syntax to import and merge all the files into one dataset. Hope someone finds it helpful.

********************************************************
* IMPORT AND MERGE ALL YEARS OF SS DATA 
********************************************************

cd "[your folder location here]"

foreach year of numlist 1880/2016 {
import delimited yob`year'.txt
gen year=`year'
save "`year'.dta", replace
clear
}

use "1880.dta", clear

foreach year of numlist 1881/2016 {
append using "`year'.dta"
}


rename v1 name
rename v2 sex
rename v3 births

save "allyears_names.dta", replace

Oh, and just for fun:

Andrew M. Lindner is Protected by Akismet | Powered by WordPress