version 9.2 clear cd `c(sysdir_plus)'/c/ drop _all freduse CPIAUCNS gen year=year(daten) gen month=month(daten) su ye local last=r(max) su month if ye==`last' local lastm=r(max) ren C c drop date* /* reshape wide c, j(month) i(year) input 1913 9.8 9.8 9.8 9.8 9.7 9.8 9.9 9.9 10.0 10.0 10.1 10.0 1914 10.0 9.9 9.9 9.8 9.9 9.9 10.0 10.2 10.2 10.1 10.2 10.1 1915 10.1 10.0 9.9 10.0 10.1 10.1 10.1 10.1 10.1 10.2 10.3 10.3 1916 10.4 10.4 10.5 10.6 10.7 10.8 10.8 10.9 11.1 11.3 11.5 11.6 1917 11.7 12.0 12.0 12.6 12.8 13.0 12.8 13.0 13.3 13.5 13.5 13.7 1918 14.0 14.1 14.0 14.2 14.5 14.7 15.1 15.4 15.7 16.0 16.3 16.5 1919 16.5 16.2 16.4 16.7 16.9 16.9 17.4 17.7 17.8 18.1 18.5 18.9 1920 19.3 19.5 19.7 20.3 20.6 20.9 20.8 20.3 20.0 19.9 19.8 19.4 end reshape long c, j(month) i(year) */ ren c cpiu su cpiu if month==12 & year==1977 replace cpiu=cpiu/r(mean)*100 gen dm=day(mdy(mo+1,1,ye)-1) if mo<12 replace dm=day(mdy(1,1,ye+1)-1) if mo==12 sort ye month file open f using cpigen.ado, write replace file write f "*! cpigen version 1.2 by Austin Nichols , compiled 1 Sep 2011" file write f "* cpigen version 1.1 by Austin Nichols , compiled 30 Jan 2008" file write f "* add quarterly calculation, split into separate prog to avoid system limit, add tsset" file write f "* cpigen version 1.0 by Austin Nichols , compiled 30 Jan 2008" file write f _n "*! program to put CPI-U and related series on current data to deflate US prices" file write f _n "*! CPI-U monthly or annual series avail Jan 1947 to `: word `lastm' of `c(Mons)'' `last'" file write f _n "*! Research series avail monthly for Dec 1977 to Dec 2005, annual for 1967 to 2005" file write f _n "*! Given variable year [and optionally month], makes variables named cpiu and cpi" file write f _n "*! CPI-U-RS and CPI-U data and discussion available from http://www.bls.gov/cpi/" file write f _n `"*! See also Kenneth J. Stewart and Stephen B. Reed, "CPI Research Series Using Current Methods, 1978-98," Monthly Labor Review, June 1999"' file write f _n "pr cpigen" _n "version 8.2" file write f _n "cap tsset" _n "if _rc==0 {" file write f _n " loc time=r(timevar)" _n `" loc ut=substr(""' _char(96) "r(unit)" _char(39) `"",1,1)"' _n " }" file write f _n "syntax [, replace]" file write f _n `"if ""' _char(96) "replace" _char(39) `""!="" cap drop cpiu"' file write f _n `"if ""' _char(96) "replace" _char(39) `""!="" cap drop cpi"' file write f _n "cap conf var year" file write f _n `"if _rc!=0 & ""' _char(96) "time" _char(39) `""=="" {"' _n `" di as err "Four-digit year must be specified by variable called " as txt "year" "' file write f _n " error 198" _n `" } "' file write f _n "else if _rc!=0 {" file write f _n `" if ""' _char(96) "ut" _char(39) `""=="." |""' _char(96) "ut" _char(39) `""=="" {"' _n `" loc ut="y""' _n " tsset, y" _n " }" file write f _n " qui g year=year(dofy(" _char(96) "time" _char(39) "))" file write f _n `" if ""' _char(96) "ut" _char(39) `""=="q" qui g quarter=quarter(dofq("' _char(96) "time" _char(39) `"))"' file write f _n `" if ""' _char(96) "ut" _char(39) `""=="m" qui g month=month(dofm("' _char(96) "time" _char(39) `"))"' file write f _n "}" file write f _n "su year, meanonly" file write f _n `"if r(max)<100 & ""' _char(96) "time" _char(39) `""!="" {"' _n `" di as err "Four-digit year must be specified by variable called " as txt "year" "' file write f _n " error 198" _n `" } "' file write f _n "qui g cpiu=." file write f _n "qui g cpi=." /* file write f _n "g cpiurs=." file write f _n `"la var cpiurs "CPI-U-RS from http://www.bls.gov/cpi/cpiurstx.htm, normalized to 1 in Dec 1977"' file write f _n "g cpiux1=." file write f _n `"la var cpiux1 "CPI-U-X1 from http://www.irp.wisc.edu/faqs/faq5.htm, normalized to 1 in 1978"' */ file write f _n "cap conf var month" file write f _n "if _rc==0 {" _n "cpigenmu" _n "cpigenm" _n "}" file write f _n "else {" _n "cap conf var quarter" file write f _n "if _rc==0 cpigenq" file write f _n "else cpigeny" file write f _n "}" _n "qui count if mi(cpiu) | mi(cpi)" file write f _n `"if r(N)>0 di as txt "(" r(N) " missing value" cond(r(N)>1,"s","") " generated)""' file write f _n "end" _n "pr cpigenmu" la var cpiu "CPIAUCNS from -freduse CPIAUCNS-, normalized to 100 in Dec 1977" su cpiu if ye==2000 & mo==12 replace cpiu=cpiu/r(mean) forv i=1/`=_N' { file write f _n "qui replace cpiu=`=cpiu[`i']' if year==`=year[`i']' & month==`=month[`i']'" } sort ye mo save mcpiufred, replace collapse cpiu [aw=dm], by(ye) sort ye compress save cpiufred, replace drop _all /* pre-2006 version CPI-U-RS data from http://www.bls.gov/cpi/cpiurstx.htm input year c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 cpi 1978 100.5 101.1 101.8 102.6 103.6 104.5 105.0 105.4 106.0 106.6 107.2 107.7 104.3 1979 108.6 109.6 110.5 111.6 112.8 114.0 114.9 115.8 116.8 117.6 118.2 119.2 114.1 1980 120.6 122.1 123.5 124.4 125.4 126.4 127.2 128.2 129.6 130.3 131.1 131.9 126.7 1981 133.1 134.8 135.9 136.6 137.4 138.1 139.2 140.1 141.2 141.8 142.3 142.8 138.6 1982 143.5 144.0 144.2 144.3 145.4 146.8 147.7 148.0 148.7 149.4 149.6 149.8 146.8 1983 150.2 150.3 150.3 151.5 152.3 152.8 153.4 153.8 154.6 154.9 155.1 155.3 152.9 1984 156.1 156.9 157.2 157.9 158.4 158.8 159.3 159.9 160.6 161.0 160.9 161.1 159.0 1985 161.3 161.9 162.6 163.3 163.9 164.4 164.7 165.0 165.6 166.0 166.5 166.9 164.3 1986 167.4 166.9 166.1 165.7 166.3 167.1 167.1 167.3 168.2 168.3 168.4 168.5 167.3 1987 169.5 170.1 170.9 171.7 172.2 172.9 173.2 174.1 174.9 175.3 175.4 175.3 173.0 1988 175.8 176.1 176.8 177.7 178.3 178.9 179.6 180.4 181.5 181.9 182.1 182.2 179.3 1989 183.0 183.7 184.7 185.9 186.8 187.3 187.8 187.9 188.6 189.3 189.6 189.9 187.0 1990 191.7 192.6 193.6 193.9 194.2 195.2 196.0 197.6 199.3 200.4 200.6 200.7 196.3 1991 201.5 201.8 201.9 202.2 202.7 203.1 203.3 203.9 204.7 204.9 205.3 205.4 203.4 1992 205.8 206.4 207.2 207.6 207.9 208.3 208.7 209.2 209.8 210.4 210.7 210.5 208.5 1993 211.1 211.9 212.5 213.1 213.5 213.7 213.8 214.3 214.6 215.3 215.5 215.3 213.7 1994 215.6 216.2 216.9 217.2 217.4 218.0 218.5 219.3 219.6 219.8 220.0 219.9 218.2 1995 220.7 221.4 222.1 222.8 223.2 223.7 223.8 224.2 224.6 225.2 225.0 224.9 223.5 1996 226.0 226.8 227.9 228.7 229.2 229.4 229.8 230.0 230.8 231.4 231.8 231.8 229.5 1997 232.5 233.2 233.6 233.9 233.9 234.2 234.3 234.7 235.5 235.9 235.8 235.4 234.4 1998 235.9 236.2 236.6 237.1 237.4 237.6 237.8 238.2 238.5 239.0 238.9 238.7 237.7 1999 239.4 239.7 240.4 242.1 242.0 242.2 242.8 243.5 244.6 245.1 245.2 245.2 242.7 2000 245.9 247.3 249.3 249.5 249.7 251.1 251.6 251.6 253.0 253.4 253.6 253.4 250.8 2001 255.0 256.0 256.6 257.6 258.7 259.3 258.4 258.5 259.6 258.7 258.3 257.3 257.8 2002 257.9 258.9 260.3 261.8 261.7 262.0 262.3 263.1 263.5 264.0 264.0 263.4 261.9 2003 264.5 266.6 268.2 267.6 267.2 267.5 267.8 268.8 269.6 269.4 268.7 268.4 267.9 2004 269.7 271.2 272.9 273.8 275.3 276.2 275.9 275.9 276.5 278.0 278.2 277.1 275.1 2005 277.6 279.3 281.4 283.3 283.1 283.2 284.5 285.9 289.4 290.1 287.8 286.5 284.3 end drop _all */ *historical CPI from ftp://ftp.bls.gov/pub/special.requests/cpi/cpiai.txt input year c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 cpi pc1 pc2 1913 9.8 9.8 9.8 9.8 9.7 9.8 9.9 9.9 10.0 10.0 10.1 10.0 9.9 1914 10.0 9.9 9.9 9.8 9.9 9.9 10.0 10.2 10.2 10.1 10.2 10.1 10.0 1.0 1.0 1915 10.1 10.0 9.9 10.0 10.1 10.1 10.1 10.1 10.1 10.2 10.3 10.3 10.1 2.0 1.0 1916 10.4 10.4 10.5 10.6 10.7 10.8 10.8 10.9 11.1 11.3 11.5 11.6 10.9 12.6 7.9 1917 11.7 12.0 12.0 12.6 12.8 13.0 12.8 13.0 13.3 13.5 13.5 13.7 12.8 18.1 17.4 1918 14.0 14.1 14.0 14.2 14.5 14.7 15.1 15.4 15.7 16.0 16.3 16.5 15.1 20.4 18.0 1919 16.5 16.2 16.4 16.7 16.9 16.9 17.4 17.7 17.8 18.1 18.5 18.9 17.3 14.5 14.6 1920 19.3 19.5 19.7 20.3 20.6 20.9 20.8 20.3 20.0 19.9 19.8 19.4 20.0 2.6 15.6 1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3 17.9 -10.8 -10.5 1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9 16.8 -2.3 -6.1 1923 16.8 16.8 16.8 16.9 16.9 17.0 17.2 17.1 17.2 17.3 17.3 17.3 17.1 2.4 1.8 1924 17.3 17.2 17.1 17.0 17.0 17.0 17.1 17.0 17.1 17.2 17.2 17.3 17.1 0.0 0.0 1925 17.3 17.2 17.3 17.2 17.3 17.5 17.7 17.7 17.7 17.7 18.0 17.9 17.5 3.5 2.3 1926 17.9 17.9 17.8 17.9 17.8 17.7 17.5 17.4 17.5 17.6 17.7 17.7 17.7 -1.1 1.1 1927 17.5 17.4 17.3 17.3 17.4 17.6 17.3 17.2 17.3 17.4 17.3 17.3 17.4 -2.3 -1.7 1928 17.3 17.1 17.1 17.1 17.2 17.1 17.1 17.1 17.3 17.2 17.2 17.1 17.1 -1.2 -1.7 1929 17.1 17.1 17.0 16.9 17.0 17.1 17.3 17.3 17.3 17.3 17.3 17.2 17.1 0.6 0.0 1930 17.1 17.0 16.9 17.0 16.9 16.8 16.6 16.5 16.6 16.5 16.4 16.1 16.7 -6.4 -2.3 1931 15.9 15.7 15.6 15.5 15.3 15.1 15.1 15.1 15.0 14.9 14.7 14.6 15.2 -9.3 -9.0 1932 14.3 14.1 14.0 13.9 13.7 13.6 13.6 13.5 13.4 13.3 13.2 13.1 13.7 -10.3 -9.9 1933 12.9 12.7 12.6 12.6 12.6 12.7 13.1 13.2 13.2 13.2 13.2 13.2 13.0 0.8 -5.1 1934 13.2 13.3 13.3 13.3 13.3 13.4 13.4 13.4 13.6 13.5 13.5 13.4 13.4 1.5 3.1 1935 13.6 13.7 13.7 13.8 13.8 13.7 13.7 13.7 13.7 13.7 13.8 13.8 13.7 3.0 2.2 1936 13.8 13.8 13.7 13.7 13.7 13.8 13.9 14.0 14.0 14.0 14.0 14.0 13.9 1.4 1.5 1937 14.1 14.1 14.2 14.3 14.4 14.4 14.5 14.5 14.6 14.6 14.5 14.4 14.4 2.9 3.6 1938 14.2 14.1 14.1 14.2 14.1 14.1 14.1 14.1 14.1 14.0 14.0 14.0 14.1 -2.8 -2.1 1939 14.0 13.9 13.9 13.8 13.8 13.8 13.8 13.8 14.1 14.0 14.0 14.0 13.9 0.0 -1.4 1940 13.9 14.0 14.0 14.0 14.0 14.1 14.0 14.0 14.0 14.0 14.0 14.1 14.0 0.7 0.7 1941 14.1 14.1 14.2 14.3 14.4 14.7 14.7 14.9 15.1 15.3 15.4 15.5 14.7 9.9 5.0 1942 15.7 15.8 16.0 16.1 16.3 16.3 16.4 16.5 16.5 16.7 16.8 16.9 16.3 9.0 10.9 1943 16.9 16.9 17.2 17.4 17.5 17.5 17.4 17.3 17.4 17.4 17.4 17.4 17.3 3.0 6.1 1944 17.4 17.4 17.4 17.5 17.5 17.6 17.7 17.7 17.7 17.7 17.7 17.8 17.6 2.3 1.7 1945 17.8 17.8 17.8 17.8 17.9 18.1 18.1 18.1 18.1 18.1 18.1 18.2 18.0 2.2 2.3 1946 18.2 18.1 18.3 18.4 18.5 18.7 19.8 20.2 20.4 20.8 21.3 21.5 19.5 18.1 8.3 1947 21.5 21.5 21.9 21.9 21.9 22.0 22.2 22.5 23.0 23.0 23.1 23.4 22.3 8.8 14.4 1948 23.7 23.5 23.4 23.8 23.9 24.1 24.4 24.5 24.5 24.4 24.2 24.1 24.1 3.0 8.1 1949 24.0 23.8 23.8 23.9 23.8 23.9 23.7 23.8 23.9 23.7 23.8 23.6 23.8 -2.1 -1.2 1950 23.5 23.5 23.6 23.6 23.7 23.8 24.1 24.3 24.4 24.6 24.7 25.0 24.1 5.9 1.3 1951 25.4 25.7 25.8 25.8 25.9 25.9 25.9 25.9 26.1 26.2 26.4 26.5 26.0 6.0 7.9 1952 26.5 26.3 26.3 26.4 26.4 26.5 26.7 26.7 26.7 26.7 26.7 26.7 26.5 0.8 1.9 1953 26.6 26.5 26.6 26.6 26.7 26.8 26.8 26.9 26.9 27.0 26.9 26.9 26.7 0.7 0.8 1954 26.9 26.9 26.9 26.8 26.9 26.9 26.9 26.9 26.8 26.8 26.8 26.7 26.9 -0.7 0.7 1955 26.7 26.7 26.7 26.7 26.7 26.7 26.8 26.8 26.9 26.9 26.9 26.8 26.8 0.4 -0.4 1956 26.8 26.8 26.8 26.9 27.0 27.2 27.4 27.3 27.4 27.5 27.5 27.6 27.2 3.0 1.5 1957 27.6 27.7 27.8 27.9 28.0 28.1 28.3 28.3 28.3 28.3 28.4 28.4 28.1 2.9 3.3 1958 28.6 28.6 28.8 28.9 28.9 28.9 29.0 28.9 28.9 28.9 29.0 28.9 28.9 1.8 2.8 1959 29.0 28.9 28.9 29.0 29.0 29.1 29.2 29.2 29.3 29.4 29.4 29.4 29.1 1.7 0.7 1960 29.3 29.4 29.4 29.5 29.5 29.6 29.6 29.6 29.6 29.8 29.8 29.8 29.6 1.4 1.7 1961 29.8 29.8 29.8 29.8 29.8 29.8 30.0 29.9 30.0 30.0 30.0 30.0 29.9 0.7 1.0 1962 30.0 30.1 30.1 30.2 30.2 30.2 30.3 30.3 30.4 30.4 30.4 30.4 30.2 1.3 1.0 1963 30.4 30.4 30.5 30.5 30.5 30.6 30.7 30.7 30.7 30.8 30.8 30.9 30.6 1.6 1.3 1964 30.9 30.9 30.9 30.9 30.9 31.0 31.1 31.0 31.1 31.1 31.2 31.2 31.0 1.0 1.3 1965 31.2 31.2 31.3 31.4 31.4 31.6 31.6 31.6 31.6 31.7 31.7 31.8 31.5 1.9 1.6 1966 31.8 32.0 32.1 32.3 32.3 32.4 32.5 32.7 32.7 32.9 32.9 32.9 32.4 3.5 2.9 1967 32.9 32.9 33.0 33.1 33.2 33.3 33.4 33.5 33.6 33.7 33.8 33.9 33.4 3.0 3.1 1968 34.1 34.2 34.3 34.4 34.5 34.7 34.9 35.0 35.1 35.3 35.4 35.5 34.8 4.7 4.2 1969 35.6 35.8 36.1 36.3 36.4 36.6 36.8 37.0 37.1 37.3 37.5 37.7 36.7 6.2 5.5 1970 37.8 38.0 38.2 38.5 38.6 38.8 39.0 39.0 39.2 39.4 39.6 39.8 38.8 5.6 5.7 1971 39.8 39.9 40.0 40.1 40.3 40.6 40.7 40.8 40.8 40.9 40.9 41.1 40.5 3.3 4.4 1972 41.1 41.3 41.4 41.5 41.6 41.7 41.9 42.0 42.1 42.3 42.4 42.5 41.8 3.4 3.2 1973 42.6 42.9 43.3 43.6 43.9 44.2 44.3 45.1 45.2 45.6 45.9 46.2 44.4 8.7 6.2 1974 46.6 47.2 47.8 48.0 48.6 49.0 49.4 50.0 50.6 51.1 51.5 51.9 49.3 12.3 11.0 1975 52.1 52.5 52.7 52.9 53.2 53.6 54.2 54.3 54.6 54.9 55.3 55.5 53.8 6.9 9.1 1976 55.6 55.8 55.9 56.1 56.5 56.8 57.1 57.4 57.6 57.9 58.0 58.2 56.9 4.9 5.8 1977 58.5 59.1 59.5 60.0 60.3 60.7 61.0 61.2 61.4 61.6 61.9 62.1 60.6 6.7 6.5 1978 62.5 62.9 63.4 63.9 64.5 65.2 65.7 66.0 66.5 67.1 67.4 67.7 65.2 9.0 7.6 1979 68.3 69.1 69.8 70.6 71.5 72.3 73.1 73.8 74.6 75.2 75.9 76.7 72.6 13.3 11.3 1980 77.8 78.9 80.1 81.0 81.8 82.7 82.7 83.3 84.0 84.8 85.5 86.3 82.4 12.5 13.5 1981 87.0 87.9 88.5 89.1 89.8 90.6 91.6 92.3 93.2 93.4 93.7 94.0 90.9 8.9 10.3 1982 94.3 94.6 94.5 94.9 95.8 97.0 97.5 97.7 97.9 98.2 98.0 97.6 96.5 3.8 6.2 1983 97.8 97.9 97.9 98.6 99.2 99.5 99.9 100.2 100.7 101.0 101.2 101.3 99.6 3.8 3.2 1984 101.9 102.4 102.6 103.1 103.4 103.7 104.1 104.5 105.0 105.3 105.3 105.3 103.9 3.9 4.3 1985 105.5 106.0 106.4 106.9 107.3 107.6 107.8 108.0 108.3 108.7 109.0 109.3 107.6 3.8 3.6 1986 109.6 109.3 108.8 108.6 108.9 109.5 109.5 109.7 110.2 110.3 110.4 110.5 109.6 1.1 1.9 1987 111.2 111.6 112.1 112.7 113.1 113.5 113.8 114.4 115.0 115.3 115.4 115.4 113.6 4.4 3.6 1988 115.7 116.0 116.5 117.1 117.5 118.0 118.5 119.0 119.8 120.2 120.3 120.5 118.3 4.4 4.1 1989 121.1 121.6 122.3 123.1 123.8 124.1 124.4 124.6 125.0 125.6 125.9 126.1 124.0 4.6 4.8 1990 127.4 128.0 128.7 128.9 129.2 129.9 130.4 131.6 132.7 133.5 133.8 133.8 130.7 6.1 5.4 1991 134.6 134.8 135.0 135.2 135.6 136.0 136.2 136.6 137.2 137.4 137.8 137.9 136.2 3.1 4.2 1992 138.1 138.6 139.3 139.5 139.7 140.2 140.5 140.9 141.3 141.8 142.0 141.9 140.3 2.9 3.0 1993 142.6 143.1 143.6 144.0 144.2 144.4 144.4 144.8 145.1 145.7 145.8 145.8 144.5 2.7 3.0 1994 146.2 146.7 147.2 147.4 147.5 148.0 148.4 149.0 149.4 149.5 149.7 149.7 148.2 2.7 2.6 1995 150.3 150.9 151.4 151.9 152.2 152.5 152.5 152.9 153.2 153.7 153.6 153.5 152.4 2.5 2.8 1996 154.4 154.9 155.7 156.3 156.6 156.7 157.0 157.3 157.8 158.3 158.6 158.6 156.9 3.3 3.0 1997 159.1 159.6 160.0 160.2 160.1 160.3 160.5 160.8 161.2 161.6 161.5 161.3 160.5 1.7 2.3 1998 161.6 161.9 162.2 162.5 162.8 163.0 163.2 163.4 163.6 164.0 164.0 163.9 163.0 1.6 1.6 1999 164.3 164.5 165.0 166.2 166.2 166.2 166.7 167.1 167.9 168.2 168.3 168.3 166.6 2.7 2.2 2000 168.8 169.8 171.2 171.3 171.5 172.4 172.8 172.8 173.7 174.0 174.1 174.0 172.2 3.4 3.4 2001 175.1 175.8 176.2 176.9 177.7 178.0 177.5 177.5 178.3 177.7 177.4 176.7 177.1 1.6 2.8 2002 177.1 177.8 178.8 179.8 179.8 179.9 180.1 180.7 181.0 181.3 181.3 180.9 179.9 2.4 1.6 2003 181.7 183.1 184.2 183.8 183.5 183.7 183.9 184.6 185.2 185.0 184.5 184.3 184.0 1.9 2.3 2004 185.2 186.2 187.4 188.0 189.1 189.7 189.4 189.5 189.9 190.9 191.0 190.3 188.9 3.3 2.7 2005 190.7 191.8 193.3 194.6 194.4 194.5 195.4 196.4 198.8 199.2 197.6 196.8 195.3 3.4 3.4 2006 198.3 198.7 199.8 201.5 202.5 202.9 203.5 203.9 202.9 201.8 201.5 201.8 201.6 2.5 3.2 2007 202.416 203.499 205.352 206.686 207.949 208.352 208.299 207.917 208.490 208.936 210.177 210.036 207.342 4.1 2.8 2008 211.080 211.693 213.528 214.823 216.632 218.815 219.964 219.086 218.783 216.573 212.425 210.228 215.303 0.1 3.8 2009 211.143 212.193 212.709 213.240 213.856 215.693 215.351 215.834 215.969 216.177 216.330 215.949 214.537 2.7 -0.4 2010 216.687 216.741 217.631 218.009 218.178 217.965 218.011 218.312 218.439 218.711 218.803 219.179 218.056 1.5 1.6 2011 220.223 221.309 223.467 224.906 225.964 225.722 225.922 end drop if mi(year) reshape long c, i(ye cpi) j(month) ren c cpiu keep year month cpiu sort year month cpiu compress save cpiu, replace drop _all * 2006 version CPI-U-RS data from http://www.bls.gov/cpi/cpiurs1978_2006.pdf * update http://www.bls.gov/cpi/cpiurs1978_2008.pdf * http://www.bls.gov/cpi/cpiursai1978_2010.pdf input year c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 cpi 1978 100.5 101.1 101.8 102.7 103.6 104.6 105.0 105.5 106.1 106.7 107.3 107.9 104.4 1979 108.7 109.7 110.7 111.8 113.0 114.1 115.2 116.0 117.1 117.9 118.5 119.5 114.4 1980 120.9 122.4 123.8 124.8 125.8 126.7 127.6 128.6 130.0 130.8 131.5 132.4 127.1 1981 133.6 135.3 136.4 137.1 137.9 138.7 139.7 140.7 141.8 142.4 142.9 143.4 139.2 1982 144.2 144.7 144.9 145.1 146.1 147.5 148.5 148.8 149.5 150.2 150.5 150.7 147.6 1983 151.1 151.2 151.3 152.4 153.2 153.8 154.4 154.8 155.6 156.0 156.2 156.4 153.9 1984 157.3 158.0 158.4 159.1 159.5 160.0 160.5 161.1 161.9 162.3 162.3 162.4 160.2 1985 162.6 163.3 164.0 164.7 165.3 165.8 166.1 166.4 167.0 167.4 167.9 168.3 165.7 1986 168.8 168.3 167.5 167.1 167.7 168.5 168.5 168.7 169.7 169.7 169.8 169.9 168.7 1987 170.9 171.6 172.3 173.2 173.7 174.3 174.6 175.6 176.4 176.8 176.9 176.8 174.4 1988 177.3 177.6 178.3 179.2 179.8 180.5 181.1 181.9 183.0 183.5 183.6 183.7 180.8 1989 184.6 185.2 186.2 187.5 188.4 188.8 189.3 189.5 190.2 190.9 191.2 191.5 188.6 1990 193.3 194.2 195.2 195.5 195.8 196.9 197.6 199.3 200.9 202.1 202.3 202.4 198.0 1991 203.3 203.5 203.6 203.9 204.4 204.9 205.0 205.6 206.4 206.6 207.1 207.2 205.1 1992 207.5 208.1 209.0 209.3 209.6 210.1 210.4 211.0 211.6 212.2 212.5 212.3 210.3 1993 212.9 213.7 214.3 214.9 215.3 215.5 215.6 216.1 216.4 217.1 217.3 217.1 215.5 1994 217.4 218.0 218.8 219.0 219.2 219.9 220.4 221.1 221.5 221.6 221.9 221.8 220.1 1995 222.6 223.3 224.0 224.7 225.1 225.6 225.7 226.1 226.5 227.1 226.9 226.8 225.4 1996 227.9 228.7 229.8 230.6 231.2 231.3 231.7 232.0 232.7 233.4 233.8 233.8 231.4 1997 234.5 235.2 235.6 235.9 235.8 236.2 236.3 236.7 237.5 237.9 237.8 237.4 236.4 1998 237.8 238.2 238.6 239.1 239.4 239.6 239.8 240.2 240.5 241.0 241.0 240.7 239.7 1999 241.4 241.7 242.4 244.1 244.1 244.2 244.9 245.6 246.7 247.2 247.3 247.3 244.7 2000 248.0 249.4 251.4 251.6 251.8 253.2 253.7 253.8 255.1 255.5 255.7 255.5 252.9 2001 257.1 258.2 258.8 259.8 260.9 261.4 260.6 260.7 261.8 260.9 260.4 259.4 260.0 2002 260.1 261.1 262.5 264.0 264.0 264.2 264.5 265.3 265.8 266.3 266.3 265.7 264.2 2003 266.8 268.9 270.5 269.9 269.5 269.8 270.1 271.1 271.9 271.7 270.9 270.6 270.1 2004 272.0 273.5 275.2 276.1 277.6 278.5 278.2 278.3 278.8 280.4 280.5 279.5 277.4 2005 280.0 281.6 283.8 285.7 285.5 285.6 286.9 288.3 291.9 292.5 290.2 288.9 286.7 2006 291.2 291.8 293.5 295.9 297.3 297.9 298.8 299.5 298.0 296.4 295.9 296.4 296.1 2007 297.2 298.8 301.6 303.5 305.4 306.0 305.9 305.3 306.2 306.8 308.6 308.4 304.5 2008 310.0 310.9 313.6 315.5 318.1 321.3 323.0 321.7 321.3 318.0 311.9 308.7 316.2 2009 310.1 311.6 312.4 313.1 314.0 316.7 316.2 316.9 317.1 317.5 317.7 317.1 315.0 2010 318.2 318.3 319.6 320.1 320.4 320.1 320.1 320.6 320.8 321.2 321.3 321.9 320.2 end reshape long c, i(ye cpi) j(month) ren c cpiur sort ye mo merge ye mo using mcpiufred, update sort ye mon replace cpiur=cpiur/100 su cpiu if yea==1977 & mo==12 replace cpiur=cpiu/r(mean) if mi(cpiur) & ye<1984 su cpiur if yea==2000 & mo==12 replace cpiur=cpiur/r(mean) file write f _n `"la var cpiu "CPI-U from -freduse CPIAUCNS-, normalized to 1 in Dec 2000"' file write f _n `"la var cpi "CPI-U-RS 1978 to present, CPI-U 47-77, renormed to 1 in Dec 2000"' file write f _n "end" _n "pr cpigenm" forval i=1/`=_N' { file write f _n "qui replace cpi=`=cpiur[`i']' if year==`=ye[`i']' & month==`=mo[`i']'" } file write f _n "end" _n "pr cpigenq" file write f _n `" di as err "Variable " as res "month" as err " missing, quarterly CPI will be generated" "' g qtr=1+((month-1)-mod((month-1),3))/3 preserve collapse cpiu cpiur [aw=dm], by(ye qtr) su cpiu if yea==2000 & qtr==4 replace cpiu=cpiu/r(mean) su cpiur if yea==2000 & qtr==4 replace cpiur=cpiur/r(mean) forv i=1/`=_N' { file write f _n "qui replace cpiu=`=cpiu[`i']' if year==`=year[`i']' & quarter==`=qtr[`i']'" file write f _n "qui replace cpi=`=cpiur[`i']' if year==`=ye[`i']' & quarter==`=qtr[`i']'" } file write f _n `"la var cpiu "CPI-U from -freduse CPIAUCNS-, normalized to 1 in 2000Q4"' file write f _n `"la var cpi "CPI-U-RS 1978 to present, CPI-U-X1 67-77, CPI-U 47-66, renormed to 1 in 2000Q4"' file write f _n "end" _n "pr cpigeny" file write f _n `" di as err "Variables " as res "month" as err " and " as res "quarter" as err " missing, annual CPI will be generated" "' restore collapse cpiur cpiu [aw=dm], by(ye) su cpiu if yea==2000 replace cpiu=cpiu/r(mean) su cpiur if yea==2000 replace cpiur=cpiur/r(mean) sort ye compress save cpiur, replace drop _all * see http://www.irp.wisc.edu/faqs/faq5.htm for CPI-U-X1, 1947 to 1993 * or http://fraser.stlouisfed.org/publications/ERP/page/7486/1600/download/7486.pdf input year cpiu_irp cpiux1 1993 144.5 144.5 1992 140.3 140.3 1991 136.2 136.2 1990 130.7 130.7 1989 124.0 124.0 1988 118.3 118.3 1987 113.6 113.6 1986 109.6 109.6 1985 107.6 107.6 1984 103.9 103.9 1983 99.6 99.6 1982 96.5 95.6 1981 90.9 90.1 1980 82.4 82.3 1979 72.6 74.0 1978 65.2 67.5 1977 60.6 63.2 1976 56.9 59.4 1975 53.8 56.2 1974 49.3 51.9 1973 44.4 47.2 1972 41.8 44.4 1971 40.5 43.1 1970 38.8 41.3 1969 36.7 39.4 1968 34.8 37.7 1967 33.4 36.3 1966 32.4 35.2 1965 31.5 34.2 1964 31.0 33.7 1963 30.6 33.3 1962 30.2 32.8 1961 29.9 32.5 1960 29.6 32.2 1959 29.1 31.6 1958 28.9 31.4 1957 28.1 30.5 1956 27.2 29.6 1955 26.8 29.1 1954 26.9 29.2 1953 26.7 29.0 1952 26.5 28.8 1951 26.0 28.3 1950 24.1 26.2 1949 23.8 25.9 1948 24.1 26.2 1947 22.3 24.2 end sort ye merge ye using cpiur drop _m sort ye merge ye using cpiufred drop _m sort ye foreach v of varlist cpiur cpiu cpiu_irp cpiux1 { su `v' if ye==1978, meanonly replace `v'=`v'/r(mean) la var `v' "Annualized `=upper("`v'")', 1 in 1978" } line cpi* ye if ye>1965, sort xli(1977) replace cpiur=cpiux1 if ye<1978 foreach v of varlist cpiur cpiu cpiu_irp cpiux1 { su `v' if ye==1967, meanonly replace `v'=`v'/r(mean) la var `v' "Annualized `=upper("`v'")', 1 in 1967" } replace cpiur=cpiu if year<1967 *li ye cpi*, noo clean foreach v of varlist cpiur cpiu cpiu_irp cpiux1 { su `v' if ye==2000, meanonly replace `v'=`v'/r(mean) la var `v' "Annualized `=upper("`v'")', 1 in 2000" } ren cpiur cpi la var cpi "Consistent CPI, renormed to 2000 dollars" note cpi: CPI-U-RS 1977 to present, CPI-U-X1 1967-1977, CPI-U pre-1967 la var cpiu "CPI-U, renormed to 2000 dollars" file write f _n `"la var cpiu "CPI-U from -freduse CPIAUCNS-, normalized to 1 in 2000"' file write f _n `"la var cpi "CPI-U-RS 1978 to present, CPI-U-X1 67-77, CPI-U 47-66, renormed to 1 in 2000"' forv i=1/`=_N' { file write f _n "qui replace cpiu=`=cpiu[`i']' if year==`=year[`i']'" } forv i=1/`=_N' { file write f _n "qui replace cpi=`=cpi[`i']' if year==`=year[`i']'" } file write f _n "end" _n "exit" line cpi* ye, sort xli(1977) xli(1967) leg(col(1)) name(allcpi, replace) keep if !mi(cpiu) keep ye cpi cpiu su cpi if ye==2000 replace cpi=cpi/r(mean) sort ye cpi save cpi, replace file close _all set obs `=_N+1' replace year=year[_n-1]+1 in l ren cpi cpiw ren cpiu cpiuw prog drop _all cpigen, replace su g quarter=1+floor(uniform()*4) ren cpi cpia ren cpiu cpiua cpigen, replace su line cpi* year, name(chk, replace) g month=1+floor(uniform()*12) cpigen, replace ren cpiu mycpiu sort year month merge year month using cpiu su cpiu if year==2000 & month==12, meanonly replace cpiu=cpiu/r(mean) gr7 mycpiu cpiu su if mycpiu<. drop _all freduse CPIAUCSL CPIAUCNS gen year=year(daten) gen month=month(daten) cpigen ren cpiu cpiu_me sort year month merge year month using cpiu foreach v in cpi cpiu cpiu_me CPIAUCSL CPIAUCNS { su `v' if ye==1977 & mo==12, meanonly qui replace `v'=`v'/r(mean) } li cpi* CPI* if ye==1977 & mo==12 li cpi* CPI* if ye==2006 & mo==12 webuse lutkepohl2, clear tsset qtr, q g year=year(dofq(qtr)) g quarter=mod(qtr,4)+1 cpigen webuse sunspot, clear cpigen, replace line cpi* ye exit