####################################################################### ####################################################################### This is the program file for the article "The P-Star Model in Five Small Economies" by Clemens J.M. Kool and John A. Tatom in the May/June 1994 REVIEW. Since nearly all of the data conversion, calcuation, and analysis was performed using Micro TSP, there's only one program in this program file. The program is the Hodrick-Prescott Filter program and is shown to be run using SAS version 6.07 . <><<><><><><><><><><><><><><><><><><><><><<><><><><><><><><<><><><<><>< Using the mnemonic code and the same variable mnemonics as those used in the data file corresponing to this program file, the variables that were filtered for this article are: " "LV1, " "LX, " "LVB, " "LREXG and " "LREXU. <><<><><><><><><><><><><><><><><><><><><><<><><><><><><><><<><><><<><>< ----------------------------------------------------------------------- ------ BEGINNING OF THE HODRICK-PRESCOTT FILTER PROGRAM --------------- ----------------------------------------------------------------------- *******************************************************************; ***** This program is set up to run one variable at a ************; ***** time. ************; ***** Make sure that the variable you wish to filter ************; ***** has no missing values. ************; *******************************************************************; */\/\/\/\/\/\/\/\ HODRICK/PRESCOTT FILTER /\/\/\/\/\/\/\/\/\/\/\; */\/\/\/\ THE SMOOTHING PARAMETER SHOULD BE: /\/\; */\/\/\/\ 100 FOR ANNUAL DATA /\/\; */\/\/\/\ 1600 FOR MONTHLY AND QUARTERLY DATA /\/\; */\/\/\/\ THERE CAN BE NO MISSING VALUES IN THE SERIES /\/\; */\/\/\/\ BEING FILTERED /\/\; */\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/; %MACRO HPFILTER(VAR=,DATASET=); PROC IML; USE &DATASET; READ ALL VAR{&VAR} INTO XDATA; S = 100; ******** SMOOTHING PARAMETER ******************; N = NROW(XDATA); IOPT = 0; SS = 0; NN = 0; T = J(N,1,0); D = J(N,1,0); V = J(N,3,0); IF ( (NN <> N) ³ (S <> SS) ³ (IOPT <> 1) ) THEN DO; SS = S; NN = N; V11 = 1; V22 = 1; V12 = 0; DO I = 3 TO N; X = V11; Z = V12; V11 = (1 / S) + (4 * (X - Z)) + V22; V12 = (2 * X) - Z; V22 = X; DET = (V11 * V22) - (V12 * V12); V(³I,1³) = (V22 / DET); V(³I,3³) = (V11 / DET); V(³I,2³) = -(V12 / DET); X = (V11 + 1); Z = V11; V11 = V11 - ((V11 * V11) / X); V22 = V22 - ((V12 * V12) / X); V12 = V12 - ((Z * V12) / X); END; END; M1 = XDATA(³2,1³); M2 = XDATA(³1,1³); DO I = 3 TO N; X = M1; M1 = (2 * M1) - M2; M2 = X; T(³I-1,1³) = (V(³I,1³) * M1) + (V(³I,2³) * M2); D(³I-1,1³) = (V(³I,2³) * M1) + (V(³I,3³) * M2); DET = (V(³I,1³) * V(³I,3³)) - (V(³I,2³) * V(³I,2³)); V11 = V(³I,3³) / DET; V12 = -(V(³I,2³) / DET); Z = (XDATA(³I,1³) - M1) / (V11 + 1); M1 = M1 + (V11 * Z); M2 = M2 + (V12 * Z); END; T(³N,1³) = M1; T(³N-1,1³) = M2; M1 = XDATA(³N-1,1³); M2 = XDATA(³N,1³); DO I = (N-2) TO 1 BY -1; I1 = I + 1; IB = N - I + 1; X = M1; M1 = (2* M1) - M2; M2 = X; IF (I > 2) THEN DO; E1 = (V(³IB,3³) * M2) + (V(³IB,2³) * M1) + T(³I,1³); E2 = (V(³IB,2³) * M2) + (V(³IB,1³) * M1) + D(³I,1³); B11 = V(³IB,3³) + V(³I1,1³); B12 = V(³IB,2³) + V(³I1,2³); B22 = V(³IB,1³) + V(³I1,3³); DET = (B11 * B22) - (B12 * B12); T(³I,1³) = ( (-B12 * E1) + (B11 * E2) ) / DET; END; DET = (V(³IB,1³) * V(³IB,3³)) - (V(³IB,2³) * V(³IB,2³)); V11 = V(³IB,3³) / DET; V12 = -(V(³IB,2³)) / DET; Z = (XDATA(³I,1³) - M1) / (V11 + 1); M1 = M1 + (V11 * Z); M2 = M2 + (V12 * Z); END; T(³1,1³) = M1; T(³2,1³) = M2; DO I = 1 TO N; D(³I,1³) = XDATA(³I,1³) - T(³I,1³); END; ALL = XDATA³³T³³D; CREATE OUTDAT FROM ALL; APPEND FROM ALL; %MEND; ********** MACRO ENDS HERE ***************; **********************************************************************; ****** This data step gathers all of the data that **************; ****** needs to be filtered. YEAR is the name for **************; ****** the variable containing the year series. **************; **********************************************************************; DATA INITIAL; INFILE AT("Your Dataset Name"); INPUT YEAR "Names of the Variables You Want to Filter"; ** the following statement deletes missing values from the data set **; IF "variable to be filtered" = . then delete; *******************************************************************; ***** This statement calls the above macro that ************; ***** performs the filtering of the variable, ************; ***** remember that you can only filter one variable ************; ***** at a time. If you wish to filter more than ************; ***** one at a time, repeat line 167 the number of ************; ***** varibles you wish to filter and insert a ************; ***** different variable name in each of the repeated ************; ***** lines or change the varible name in line 167 ************; ***** and run the program for each change. ************; *******************************************************************; %HPFILTER(VAR="Name of variable you want to filter", DATASET=INITIAL); *******************************************************************; ***** This dataset is simply the result of the ************; ***** Hodrick-Prescott Filter and the variables are ************; ***** renamed to anything you desire. By merging ************; ***** with the INITIAL dataset, your RESULT dataset ************; ***** will also contain the YEAR variable. ************; *******************************************************************; DATA RESULT; MERGE INITIAL(KEEP=YEAR) OUTDAT; "Actual Data Series" = COL1; "Trend Result of Data Series" = COL2; "Deviation from Trend" = COL3; PROC PRINT; ----------------------------------------------------------------------- ------ END OF THE HODRICK-PRESCOTT FILTER PROGRAM --------------------- -----------------------------------------------------------------------