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, MAP= <series>, SMPL) <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.

MAP= series computes SUM (default) or AVERAGE from an old series and stores it in a new series, using a MAP of pointers. This is helpful for aggregating grouped data, such as industries, states, or individuals with panel data. The rows of the map correspond to the rows in the old series. The values in the map correspond to the rows of the new series. Zero values mean the observation is not mapped to the new series. The SMPL option is the default when MAP is used, and it puts the map and old series under the control of the current SMPL, while the new output series will be FREQ N, starting at observation 1. If NOSMPL is used, the traditional CONVERT method is used, where the old and map series are used at their maximum defined lengths, and the current FREQ/SMPL are only used to determine the FREQ and starting point of the new series. With NOSMPL, the map and old series must be defined over exactly the same set of observations. The map cannot contain any missing values or contain only zeroes. The old series can contain missing values; they will result in missing values in the new series if the observations are mapped. If no observations of the old series are mapped to a given element of the new series, the element is given the value zero (for both sum and average). The length of the new series is equal to the maximum value in the map series.

SMPL/NOSMPL applies only when the MAP option is used. Otherwise the default is NOSMPL (use all the data in the series).

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

Example of the MAP= option:

SMPL 1 5 ;

TREND T ;

READ MAPS; 0 1 2 2 3 ;

CONVERT (MAP=MAPS,AVE) AT = T ;

CONVERT (MAP=MAPS,SUM) ST = T ;

which yields the following:

AT

ST

2

2

3.5

7

5

5