/* Data Downloaded from the Federal Reserve Bank of St. Louis FRED Data Base. The variable downloaded is labeled GDPC1: Billions of Chained 2005 Dollars, Quarterly, Seasonally Adjusted Annual Rate. The time span of the data is 1947Q1 - 2012Q3. I imported the data into EXCEL from FRED and then "block copied" the data from the EXCEL spreadsheet into the below data step in the SAS program. */ DATA RGDP; INPUT date yymmdd11. rgdp; /* Note the SAS Informat "yymmdd11." that was used to read in the date variable provided by FRED. */ grgdp = (log(rgdp) - lag(log(rgdp)))*400; /* Approximate Method for calculating annual growth rates */ r = (rgdp - lag(rgdp))/lag(rgdp); grgdp2 = ((1 + r)**4 - 1)*100; /* Exact Method for calculating annual growth rates */ datalines; 1947-01-01 1770.7 1947-04-01 1768.0 1947-07-01 1766.5 1947-10-01 1793.3 1948-01-01 1821.8 1948-04-01 1855.3 1948-07-01 1865.3 1948-10-01 1868.2 1949-01-01 1842.2 1949-04-01 1835.5 1949-07-01 1856.1 1949-10-01 1838.7 1950-01-01 1913.0 1950-04-01 1971.2 1950-07-01 2048.4 1950-10-01 2084.4 1951-01-01 2110.7 1951-04-01 2145.7 1951-07-01 2188.5 1951-10-01 2192.2 1952-01-01 2214.3 1952-04-01 2216.7 1952-07-01 2231.6 1952-10-01 2305.3 1953-01-01 2348.4 1953-04-01 2366.2 1953-07-01 2351.8 1953-10-01 2314.6 1954-01-01 2303.5 1954-04-01 2306.4 1954-07-01 2332.4 1954-10-01 2379.1 1955-01-01 2447.7 1955-04-01 2488.1 1955-07-01 2521.4 1955-10-01 2535.5 1956-01-01 2523.9 1956-04-01 2543.8 1956-07-01 2540.6 1956-10-01 2582.1 1957-01-01 2597.9 1957-04-01 2591.7 1957-07-01 2616.6 1957-10-01 2589.1 1958-01-01 2519.0 1958-04-01 2534.5 1958-07-01 2593.9 1958-10-01 2654.3 1959-01-01 2708.0 1959-04-01 2776.4 1959-07-01 2773.1 1959-10-01 2782.8 1960-01-01 2845.3 1960-04-01 2832.0 1960-07-01 2836.6 1960-10-01 2800.2 1961-01-01 2816.9 1961-04-01 2869.6 1961-07-01 2915.9 1961-10-01 2975.3 1962-01-01 3028.7 1962-04-01 3062.1 1962-07-01 3090.4 1962-10-01 3097.9 1963-01-01 3138.4 1963-04-01 3177.7 1963-07-01 3237.6 1963-10-01 3262.2 1964-01-01 3335.4 1964-04-01 3373.7 1964-07-01 3419.5 1964-10-01 3429.0 1965-01-01 3513.3 1965-04-01 3560.9 1965-07-01 3633.2 1965-10-01 3720.8 1966-01-01 3812.2 1966-04-01 3824.9 1966-07-01 3850.0 1966-10-01 3881.2 1967-01-01 3915.4 1967-04-01 3916.2 1967-07-01 3947.5 1967-10-01 3977.6 1968-01-01 4059.5 1968-04-01 4128.5 1968-07-01 4156.7 1968-10-01 4174.7 1969-01-01 4240.5 1969-04-01 4252.8 1969-07-01 4279.7 1969-10-01 4259.6 1970-01-01 4252.9 1970-04-01 4260.7 1970-07-01 4298.6 1970-10-01 4253.0 1971-01-01 4370.3 1971-04-01 4395.1 1971-07-01 4430.2 1971-10-01 4442.5 1972-01-01 4521.9 1972-04-01 4629.1 1972-07-01 4673.5 1972-10-01 4750.5 1973-01-01 4872.0 1973-04-01 4928.4 1973-07-01 4902.1 1973-10-01 4948.8 1974-01-01 4905.4 1974-04-01 4918.0 1974-07-01 4869.4 1974-10-01 4850.2 1975-01-01 4791.2 1975-04-01 4827.8 1975-07-01 4909.1 1975-10-01 4973.3 1976-01-01 5086.3 1976-04-01 5124.6 1976-07-01 5149.7 1976-10-01 5187.1 1977-01-01 5247.3 1977-04-01 5351.6 1977-07-01 5447.3 1977-10-01 5446.1 1978-01-01 5464.7 1978-04-01 5679.7 1978-07-01 5735.4 1978-10-01 5811.3 1979-01-01 5821.0 1979-04-01 5826.4 1979-07-01 5868.3 1979-10-01 5884.5 1980-01-01 5903.4 1980-04-01 5782.4 1980-07-01 5771.7 1980-10-01 5878.4 1981-01-01 6000.6 1981-04-01 5952.7 1981-07-01 6025.0 1981-10-01 5950.0 1982-01-01 5852.3 1982-04-01 5884.0 1982-07-01 5861.4 1982-10-01 5866.0 1983-01-01 5938.9 1983-04-01 6072.4 1983-07-01 6192.2 1983-10-01 6320.2 1984-01-01 6442.8 1984-04-01 6554.0 1984-07-01 6617.7 1984-10-01 6671.6 1985-01-01 6734.5 1985-04-01 6791.5 1985-07-01 6897.6 1985-10-01 6950.0 1986-01-01 7016.8 1986-04-01 7045.0 1986-07-01 7112.9 1986-10-01 7147.3 1987-01-01 7186.9 1987-04-01 7263.3 1987-07-01 7326.3 1987-10-01 7451.7 1988-01-01 7490.2 1988-04-01 7586.4 1988-07-01 7625.6 1988-10-01 7727.4 1989-01-01 7799.9 1989-04-01 7858.3 1989-07-01 7920.6 1989-10-01 7937.9 1990-01-01 8020.8 1990-04-01 8052.7 1990-07-01 8052.6 1990-10-01 7982.0 1991-01-01 7943.4 1991-04-01 7997.0 1991-07-01 8030.7 1991-10-01 8062.2 1992-01-01 8150.7 1992-04-01 8237.3 1992-07-01 8322.3 1992-10-01 8409.8 1993-01-01 8425.3 1993-04-01 8479.2 1993-07-01 8523.8 1993-10-01 8636.4 1994-01-01 8720.5 1994-04-01 8839.8 1994-07-01 8896.7 1994-10-01 8995.5 1995-01-01 9017.6 1995-04-01 9037.0 1995-07-01 9112.9 1995-10-01 9176.4 1996-01-01 9239.3 1996-04-01 9399.0 1996-07-01 9480.8 1996-10-01 9584.3 1997-01-01 9658.0 1997-04-01 9801.2 1997-07-01 9924.2 1997-10-01 10000.3 1998-01-01 10094.8 1998-04-01 10185.6 1998-07-01 10320.0 1998-10-01 10498.6 1999-01-01 10592.1 1999-04-01 10674.9 1999-07-01 10810.7 1999-10-01 11004.8 2000-01-01 11033.6 2000-04-01 11248.8 2000-07-01 11258.3 2000-10-01 11325.0 2001-01-01 11287.8 2001-04-01 11361.7 2001-07-01 11330.4 2001-10-01 11370.0 2002-01-01 11467.1 2002-04-01 11528.1 2002-07-01 11586.6 2002-10-01 11590.6 2003-01-01 11638.9 2003-04-01 11737.5 2003-07-01 11930.7 2003-10-01 12038.6 2004-01-01 12117.9 2004-04-01 12195.9 2004-07-01 12286.7 2004-10-01 12387.2 2005-01-01 12515.0 2005-04-01 12570.7 2005-07-01 12670.5 2005-10-01 12735.6 2006-01-01 12896.4 2006-04-01 12948.7 2006-07-01 12950.4 2006-10-01 13038.4 2007-01-01 13056.1 2007-04-01 13173.6 2007-07-01 13269.8 2007-10-01 13326.0 2008-01-01 13266.8 2008-04-01 13310.5 2008-07-01 13186.9 2008-10-01 12883.5 2009-01-01 12711.0 2009-04-01 12701.0 2009-07-01 12746.7 2009-10-01 12873.1 2010-01-01 12947.6 2010-04-01 13019.6 2010-07-01 13103.5 2010-10-01 13181.2 2011-01-01 13183.8 2011-04-01 13264.7 2011-07-01 13306.9 2011-10-01 13441.0 2012-01-01 13506.4 2012-04-01 13548.5 2012-07-01 13652.5 ; /* Notice the use of the semicolon (;) as the end-of-file marker to tell SAS that this is the end of the data. */ /* Here we print out the data to see how similar the two different calculations of the annual growth rate (grgdp and grgdp2) are. They are very similar and therefore we choose to go with the conventional calculation of growth rates grgdp. Also notice that the "format" statement asks SAS to print out the dates of the data using the conventional and easy to read YYQ format as compared to SAS dates that are centered around the days beginning at January 1, 1960. */ proc print data = rgdp; format date YYQ6.; run; /* Here we plot the original real gdp series spanning the dates 1947Q1 - 2012Q3. */ proc gplot data=rgdp; symbol v=dot c=black i=join h=.4; title1 'Real GDP Time Series'; title2 'X=Date Y=RGDP Series'; axis1 label=(f=duplex 'Date'); axis2 label=(f=duplex 'Real GDP Series'); plot rgdp*date / haxis=axis1 vaxis=axis2; format date YYQ6.; run; /* In the next two graphs we plot the annual growth rates in the real gdp data using, first, the approximate method and then, second, the exact method. Notice these series are very similar. */ proc gplot data=rgdp; symbol v=dot c=black i=join h=.4; title1 'Annual Growth Rate of Real GDP - First Method'; title2 'X=Date Y=Growth in RGDP'; axis1 label=(f=duplex 'Date'); axis2 label=(f=duplex 'Growth in Real GDP'); plot grgdp*date / haxis=axis1 vaxis=axis2; format date YYQ6.; run; proc gplot data=rgdp; symbol v=dot c=black i=join h=.4; title1 'Annual Growth Rate of Real GDP - Second Method'; title2 'X=Date Y=Growth in RGDP'; axis1 label=(f=duplex 'Date'); axis2 label=(f=duplex 'Growth in Real GDP'); plot grgdp2*date / haxis=axis1 vaxis=axis2; format date YYQ6.; run; /* As it seems the variability of the growth series from 1947Q1 - 1979Q4 is substantially larger than the variability of the growth series from 1980Q1 - 2012Q3 we choose to focus on forecasting the latter part of the growth time series. */ data last; set rgdp; If _n_ >= 133; /* Beginning 1980Q1. The variable "_N_" is a system variable that assigns a number to each observation that is read in by SAS. The observation associated with 1947Q1 have _n_ = 1 whereas the observation associated with 2012Q3 is _N_ = 263. */ run; /* Here we print out and plot the data to see that we have the segment of the data that we want to analyze. */ proc print data = last; format date yyq6.; run; proc gplot data=last; symbol v=dot c=black i=join h=.4; title1 'Annual Growth Rate of Real GDP - 1980Q1 - 2012Q3'; title2 'X=Date Y=Growth in RGDP'; axis1 label=(f=duplex 'Date'); axis2 label=(f=duplex 'Growth in Real GDP'); plot grgdp2*date / haxis=axis1 vaxis=axis2; format date YYQ6.; run; /* Here we use the SAS Procedure "ARIMA" to estimate an AR(1) Box-Jenkins model of the grouwth series in this last data span and produce corresponding point forecasts for 1 through 4-steps ahead with accompanying 95% prediction intervals. Notice that the very last realized value of Real GDP growth is 3.10599% (2012Q3) whereas the Box-Jenkins AR(1) model estimates the mean of the growth series over the period to be 2.56016%. As is the property of AR(1) forecasts, the predictions regress toward the mean (2.56016%) and the prediction intervals become wider as the forecast horizon increases. */ proc arima data = last; identify var = grgdp; estimate p = 1; forecast lead = 4; run;