Example 15.1 Combining Monthly and Quarterly Data
This example combines monthly and quarterly data sets by interpolating monthly values for the quarterly series. The series are extracted from two small sample data sets stored in the SASHELP library. These data sets were contributed by Citicorp Data Base services and contain selected U.S. macro economic series.
The quarterly series gross domestic product (GDP) and implicit price deflator (GD) are extracted from SASHELP.CITIQTR. The monthly series industrial production index (IP) and unemployment rate (LHUR) are extracted from SASHELP.CITIMON. Only observations for the years 1990 and 1991 are selected. PROC EXPAND is then used to interpolate monthly estimates for the quarterly series, and the interpolated series are merged with the monthly data.
The following statements extract and print the quarterly data, shown in Output 15.1.1.
data qtrly;
set sashelp.citiqtr;
where date >= '1jan1990'd &
date < '1jan1992'd ;
keep date gdp gd;
run;
title "Quarterly Data";
proc print data=qtrly;
run;
Output 15.1.1
Quarterly Data Set
1990:1 |
111.100 |
5422.40 |
1990:2 |
112.300 |
5504.70 |
1990:3 |
113.600 |
5570.50 |
1990:4 |
114.500 |
5557.50 |
1991:1 |
115.900 |
5589.00 |
1991:2 |
116.800 |
5652.60 |
1991:3 |
117.400 |
5709.20 |
1991:4 |
. |
5736.60 |
The following statements extract and print the monthly data, shown in Output 15.1.2.
data monthly;
set sashelp.citimon;
where date >= '1jan1990'd &
date < '1jan1992'd ;
keep date ip lhur;
run;
title "Monthly Data";
proc print data=monthly;
run;
Output 15.1.2
Monthly Data Set
JAN1990 |
107.500 |
5.30000 |
FEB1990 |
108.500 |
5.30000 |
MAR1990 |
108.900 |
5.20000 |
APR1990 |
108.800 |
5.40000 |
MAY1990 |
109.400 |
5.30000 |
JUN1990 |
110.100 |
5.20000 |
JUL1990 |
110.400 |
5.40000 |
AUG1990 |
110.500 |
5.60000 |
SEP1990 |
110.600 |
5.70000 |
OCT1990 |
109.900 |
5.80000 |
NOV1990 |
108.300 |
6.00000 |
DEC1990 |
107.200 |
6.10000 |
JAN1991 |
106.600 |
6.20000 |
FEB1991 |
105.700 |
6.50000 |
MAR1991 |
105.000 |
6.70000 |
APR1991 |
105.500 |
6.60000 |
MAY1991 |
106.400 |
6.80000 |
JUN1991 |
107.300 |
6.90000 |
JUL1991 |
108.100 |
6.80000 |
AUG1991 |
108.000 |
6.80000 |
SEP1991 |
108.400 |
6.80000 |
OCT1991 |
108.200 |
6.90000 |
NOV1991 |
108.000 |
6.90000 |
DEC1991 |
107.800 |
7.10000 |
The following statements interpolate monthly estimates for the quarterly series and merge the interpolated series with the monthly data. The resulting combined data set is then printed, as shown in Output 15.1.3.
proc expand data=qtrly out=temp from=qtr to=month;
convert gdp gd / observed=average;
id date;
run;
data combined;
merge monthly temp;
by date;
run;
title "Combined Data Set";
proc print data=combined;
run;
Output 15.1.3
Combined Data Set
JAN1990 |
107.500 |
5.30000 |
5409.69 |
110.879 |
FEB1990 |
108.500 |
5.30000 |
5417.67 |
111.048 |
MAR1990 |
108.900 |
5.20000 |
5439.39 |
111.367 |
APR1990 |
108.800 |
5.40000 |
5470.58 |
111.802 |
MAY1990 |
109.400 |
5.30000 |
5505.35 |
112.297 |
JUN1990 |
110.100 |
5.20000 |
5538.14 |
112.801 |
JUL1990 |
110.400 |
5.40000 |
5563.38 |
113.264 |
AUG1990 |
110.500 |
5.60000 |
5575.69 |
113.641 |
SEP1990 |
110.600 |
5.70000 |
5572.49 |
113.905 |
OCT1990 |
109.900 |
5.80000 |
5561.64 |
114.139 |
NOV1990 |
108.300 |
6.00000 |
5553.83 |
114.451 |
DEC1990 |
107.200 |
6.10000 |
5556.92 |
114.909 |
JAN1991 |
106.600 |
6.20000 |
5570.06 |
115.452 |
FEB1991 |
105.700 |
6.50000 |
5588.18 |
115.937 |
MAR1991 |
105.000 |
6.70000 |
5608.68 |
116.314 |
APR1991 |
105.500 |
6.60000 |
5630.81 |
116.600 |
MAY1991 |
106.400 |
6.80000 |
5652.92 |
116.812 |
JUN1991 |
107.300 |
6.90000 |
5674.06 |
116.988 |
JUL1991 |
108.100 |
6.80000 |
5693.43 |
117.164 |
AUG1991 |
108.000 |
6.80000 |
5710.54 |
117.380 |
SEP1991 |
108.400 |
6.80000 |
5724.11 |
117.665 |
OCT1991 |
108.200 |
6.90000 |
5733.65 |
. |
NOV1991 |
108.000 |
6.90000 |
5738.46 |
. |
DEC1991 |
107.800 |
7.10000 |
5737.75 |
. |
Copyright © SAS Institute Inc. All rights reserved.