/* Function to Get cola index for a given year
http://www.socialsecurity.gov/cola/automatic-cola.htm
-----------------------------------------------------*/

program define _gcola
	version 9, missing
	gettoken type 0 : 0
	gettoken cola 0 : 0
	gettoken eqs 0 : 0			/* "=" */
	gettoken paren 0 : 0, parse("(), ")	/* "(" */
	gettoken year 0 : 0, parse("(), ")
	gettoken paren 0 : 0, parse("(), ")	/* "(" */
	syntax [if] [in] [, BY(string)]
		marksample touse
		global result `cola'
		global where `year'
		global selected `touse'
		qui gen $result = . if $selected
		getcola
end

program define colafor
	qui replace $result = `2' if $where==`1' & $selected
end

program define getcola
colafor 1937  1
colafor 1938  1
colafor 1939  1
colafor 1940  1
colafor 1941  1
colafor 1942  1
colafor 1943  1
colafor 1944  1
colafor 1945  1
colafor 1946  1
colafor 1947  1
colafor 1948  1
colafor 1949  1
colafor 1950  1
colafor 1951  1
colafor 1952  1
colafor 1953  1
colafor 1954  1
colafor	1955	1
colafor	1956	1
colafor	1957	1
colafor	1958	1
colafor	1959	1
colafor	1960	1
colafor	1961	1
colafor	1962	1
colafor	1963	1
colafor	1964	1
colafor	1965	1
colafor	1966	1
colafor	1967	1
colafor	1968	1
colafor	1969	1
colafor	1970	1
colafor	1971	1
colafor	1972	1
colafor	1973	1
colafor	1974	1
colafor	1975	1.08
colafor	1976	1.14912
colafor	1977	1.21691808
colafor	1978	1.296017755
colafor	1979	1.424323513
colafor	1980	1.628001775
colafor	1981	1.810337974
colafor	1982	1.944302984
colafor	1983	1.944302984
colafor	1984	2.012353589
colafor	1985	2.082785964
colafor	1986	2.147352329
colafor	1987	2.175267909
colafor	1988	2.266629162
colafor	1989	2.357294328
colafor	1990	2.468087162
colafor	1991	2.601363868
colafor	1992	2.697614331
colafor	1993	2.778542761
colafor	1994	2.850784873
colafor	1995	2.93060685
colafor	1996	3.006802628
colafor	1997	3.093999904
colafor	1998	3.158973902
colafor	1999	3.200040563
colafor	2000	3.280041577
colafor	2001	3.394843032
colafor	2002	3.483108951
colafor	2003	3.531872476
colafor	2004	3.606041798
colafor	2005	3.703404927
colafor	2006	3.855244528
colafor	2007	3.982467598
colafor	2008	4.074064353
colafor	2009	4.074064353
colafor	2010	4.074064353
colafor	2011	4.074064353
colafor	2012	4.074064353
colafor	2013	4.074064353
colafor	2014	4.074064353
colafor	2015	4.074064353
colafor	2016	4.074064353
colafor	2017	4.074064353
colafor	2018	4.074064353
colafor	2019	4.074064353
colafor	2020	4.074064353
colafor	2021	4.074064353
colafor	2022	4.074064353
colafor	2023	4.074064353
colafor	2024	4.074064353
colafor	2025	4.074064353
colafor	2026	4.074064353
colafor	2027	4.074064353
colafor	2028	4.074064353
colafor	2029	4.074064353
colafor	2030	4.074064353
colafor	2031	4.074064353
colafor	2032	4.074064353
colafor	2033	4.074064353
colafor	2034	4.074064353
colafor	2035	4.074064353
colafor	2036	4.074064353
colafor	2037	4.074064353
colafor	2038	4.074064353
colafor	2039	4.074064353
colafor	2040	4.074064353
colafor	2041	4.074064353
colafor	2042	4.074064353
colafor	2043	4.074064353
colafor	2044	4.074064353
colafor	2045	4.074064353
colafor	2046	4.074064353
colafor	2047	4.074064353
colafor	2048	4.074064353
colafor	2049	4.074064353
colafor	2050	4.074064353
end