cls
set more off
global nipa "C:\Users\jed\Dropbox\research\PIIE\GDP and NIPA"

adopath + "C:\x13sam"

* this is the monthly population series from the BEA NIPS flat file

* download flat files here: https://apps.bea.gov/iTable/?isuri=1&reqid=19&step=4&categories=flatfiles&nipa_table_list=1


import delimited "$nipa\NipaDataM.txt", varnames(1) encoding(ISO-8859-2) clear
keep if strpos(seriescode, "B230RC")>0
drop seriescode
destring value, replace ignore(",")
gen date = monthly(period, "YM")
tsset date, monthly
gen growth=(value/L1.value)^12-1
twoway line growth date if date>=721

replace value=value/1000
keep if yofd(dofm(date))>=1990

* seasonal adjustment
sax13 value
sax13im value, ext(s11)
sax13del value

gen growth_sa=(value_s11/L1.value_s11)^12-1
twoway line growth growth_sa date
gen year=yofd(dofm(date))
outsheet using "$nipa\bea_population.csv", comma replace
