EXPAND Procedure

Example 15.1 Combining Monthly and Quarterly Data

(View the complete code for this example.)

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

Quarterly Data

ObsDATEGDGDP
11990:1111.1005422.40
21990:2112.3005504.70
31990:3113.6005570.50
41990:4114.5005557.50
51991:1115.9005589.00
61991:2116.8005652.60
71991:3117.4005709.20
81991: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

Monthly Data

ObsDATEIPLHUR
1JAN1990107.5005.30000
2FEB1990108.5005.30000
3MAR1990108.9005.20000
4APR1990108.8005.40000
5MAY1990109.4005.30000
6JUN1990110.1005.20000
7JUL1990110.4005.40000
8AUG1990110.5005.60000
9SEP1990110.6005.70000
10OCT1990109.9005.80000
11NOV1990108.3006.00000
12DEC1990107.2006.10000
13JAN1991106.6006.20000
14FEB1991105.7006.50000
15MAR1991105.0006.70000
16APR1991105.5006.60000
17MAY1991106.4006.80000
18JUN1991107.3006.90000
19JUL1991108.1006.80000
20AUG1991108.0006.80000
21SEP1991108.4006.80000
22OCT1991108.2006.90000
23NOV1991108.0006.90000
24DEC1991107.8007.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

Combined Data Set

ObsDATEIPLHURGDPGD
1JAN1990107.5005.300005409.69110.879
2FEB1990108.5005.300005417.67111.048
3MAR1990108.9005.200005439.39111.367
4APR1990108.8005.400005470.58111.802
5MAY1990109.4005.300005505.35112.297
6JUN1990110.1005.200005538.14112.801
7JUL1990110.4005.400005563.38113.264
8AUG1990110.5005.600005575.69113.641
9SEP1990110.6005.700005572.49113.905
10OCT1990109.9005.800005561.64114.139
11NOV1990108.3006.000005553.83114.451
12DEC1990107.2006.100005556.92114.909
13JAN1991106.6006.200005570.06115.452
14FEB1991105.7006.500005588.18115.937
15MAR1991105.0006.700005608.68116.314
16APR1991105.5006.600005630.81116.600
17MAY1991106.4006.800005652.92116.812
18JUN1991107.3006.900005674.06116.988
19JUL1991108.1006.800005693.43117.164
20AUG1991108.0006.800005710.54117.380
21SEP1991108.4006.800005724.11117.665
22OCT1991108.2006.900005733.65.
23NOV1991108.0006.900005738.46.
24DEC1991107.8007.100005737.75.


Last updated: June 19, 2025