CONVERT

Options     Examples

CONVERT changes series from one frequency to another. The options specify the method used for conversion: averaging the data, using the first, middle or last observation, or summing the data. Interpolation is optionally available for converting to higher frequencies.

CONVERT (AVERAGE or FIRST or MID or LAST or SUM, INTERPOL)

                     <list of series names> ;

or

                     newseries = oldseries ;

Usage

Use CONVERT after specifying the frequency you want to convert to with a FREQ statement. The frequency you convert from will be that of the series to be converted. The SMPL information is ignored so that the entire series is converted; this avoids the confusion of possibly mixing frequencies in the same series.

The first form of the command simply converts the series and stores it back in data storage under the same name; in this case more than one series can be converted at a time. The second form takes the old series on the right hand side of the equal sign, converts it to the new FREQ and stores it under the new series name; only one series may be converted in this way on each command.

Depending on the type of series you are converting, you can specify various methods of aggregating or "disaggregating" the series; if you do not say anything and you are converting to a lower frequency, CONVERT will average all the observations within an interval to produce a value for that interval. The default for converting to a higher frequency is to duplicate the value for all observations in the new interval; unless the INTERPOL or SUM option is used.

Output

CONVERT produces no printed output. It stores one converted series in data storage.

Options

AVERAGE forms the new series by averaging all the observations within a period. This is the default.

FIRST forms the new series by choosing the first observation in the period.

MID forms the new series by choosing the middle observation in the period. If the number of observations per period is even, CONVERT uses the one before the halfway point.

LAST forms the new series by choosing the last observation in the period.

SUM forms the new series by summing all the observations in the period. If converting from a lower frequency to a higher, the new values are divided by the conversion ratio (e.g., by four, if converting from annual to quarterly).

Only one of the above options should be included.

INTERPOL/NOINTERP specifies linear interpolation when converting to a higher frequency (the default is to duplicate observations rather than interpolate). INTERPOL is used in conjunction with one of the other options to determine the placement of the peak value.

Examples

FREQ A ;

CONVERT (AVERAGE) UNEMP ;   CONVERT (SUM) SALES ;

CONVERT (LAST) PCLOSE = PRICE ;

Assume that UNEMP and SALES are quarterly variables and PRICE is a monthly variable. The statements above convert the unemployment rate by averaging the quarterly rates over the year, but convert sales from quarterly to annual by adding them, since they are a flow variable. The end of year price (PCLOSE) is obtained by using the December observation of the monthly price variable.

FREQ A ; SMPL 70, 72 ;

READ X ; 10 20 40 ;

FREQ Q ;

CONVERT DX = X ; CONVERT (SUM) SX=X ; CONVERT (INTER,LAST) IX = X ;

results in

 

DX

SX

IX

70:1

10

2.5

2.5

70:2

10

2.5

5.0

70:3

10

2.5

7.5

70:4

10

2.5

10

.

.

.

.

.

.

.

.

.

.

.

.

72:1

40

10

25

72:2

40

10

30

72:3

40

10

35

72:4

40

10

40