The SASEFRED Interface Engine

The LIBNAME libref SASEFRED Statement

  • LIBNAME libref SASEFRED 'physical-name' options;

The LIBNAME statement assigns a SAS library reference (libref) to the physical path of the directory of FRED data files in which the downloaded FRED XML data are stored. The required 'physical name' argument specifies the location of the folder where your FRED XML data reside. It should end with a backslash if you are in a Windows environment and a forward slash if you are in a UNIX environment.

You can specify the following options in the LIBNAME libref SASEFRED statement.

APIKEY='fred_apikey'

specifies the FRED access key that enables you to access the data provided by the FRED website. The FRED access key is a 32-character alphanumeric lowercase string, and it is required. You can request your fred_apikey by visiting the website at the following URL:

http://api.stlouisfed.org/api_key.html

OUTXML=fred_xmlfile

specifies the name of the file where the XML data that are returned from the FRED website are stored.

AUTOMAP=fred_automap

specifies whether to overwrite the existing XMLmap file (AUTOMAP=REPLACE) or not to overwrite the existing XMLmap file (AUTOMAP=REUSE). You can set fred_automap to REUSE so that a pre-existing XMLmap file named by the XMLMAP= option is used. You can set fred_automap to REPLACE so that the most current XMLmap generated by the SASEFRED engine and named by the XMLMAP= option is used.

XMLMAP=fred_xmlmapfile

specifies the fully qualified name of the location where the XMLmap file is automatically stored.

MAPREF=fred_xmlmapref

specifies the fileref used for the map assignment. For an example of the SASEFRED engine that uses the MAPREF= and the XMLMAP= options in the FILENAME statement to assign a filename, as in the following, see the section Reading Price Data by Using Indices:

   FILENAME MyMap "U:\fred\test\gstart.map";

You can use the MAPREF= and XMLMAP= options to control where the map resides, what you name the map, and how you refer to it with a fileref. You can use the OUTXML= option to name your XML data file. It is placed in the folder designated by ‘physical-name’, and you can reference it by using the myLib libref in your SASEFRED LIBNAME statement. This is shown in the section Getting Started: SASEFRED Interface Engine, inside the DATA step in the SET statement. The SET statement reads observations from the input data set myLib.gstart and stores them in a SAS data set named Company_pvol.

IDLIST=‘fred_idlist’

specifies the list of time series to be included in the output SAS data set. This list is comma delimited and must be enclosed in single quotation marks.

START=‘fred_startdate’

specifies the start date for the time series in the format YYYY-MM-DD. START= is optional, and the default is 1776-07-04 (earliest available). When you use the OUTPUT=1 option (observation by real-time period) and the UNITS='chg' option, it is important to specify a date in the START= option that is later than the series observation start date, Obs_Start. Failure to do so forces the SASEFRED interface engine to change UNITS='chg' to UNITS='lin'.

END=‘fred_enddate’

specifies the end date for the time series in the format YYYY-MM-DD. END= is optional, and the default is 9999-12-31 (latest available).

FREQ=‘fred_frequency’

specifies a lower frequency to aggregate values to. The FRED frequency aggregation feature converts higher-frequency time series to lower-frequency time series (such as converting a daily time series to a monthly time series). In FRED, the highest frequency is daily, and the lowest frequency is annual. The fred_frequency argument is optional, and there is no default value for no frequency aggregation. The valid frequency arguments are presented in Table 39.5.

Note: An error is returned if you specify a frequency that is higher than the native frequency of the series. For example, if a series has the native frequency 'Annually', it is not possible to aggregate the series to the higher 'Monthly' frequency by using the frequency parameter value 'm'. To find the native frequency of an economic time series, enter the following URL in your web browser. The output includes the 'Frequency' field, which shows native frequency of that time series.

http://api.stlouisfed.org/fred/series?series_id=DJCA&api_key=your_fred_apikey

Note: When a single time series is specified in the IDLIST= option and the FREQ= option is not specified or is an empty string, then the native frequency of that time series is used as the reporting frequency. When multiple time series are specified in the IDLIST= option, then the 'Annual' frequency is used as the reporting frequency unless the reporting frequency is specified in the FREQ= option. If any time series in the IDLIST= option list have a lower native frequency than the requested frequency, then those time series are dropped from the list and excluded from the output.

AGG=‘fred_aggregation’

specifies the aggregation method used for frequency aggregation. It is optional. The valid aggregation arguments are ’avg’ for averaging, ’sum’ for summation, and ’eop’ for end of period. The default is AGG=’avg’. The AGG= option has no effect if the frequency option (FREQ=) is not set.

LIMIT=fred_limit

specifies the maximum number of rows (time series observations) to return, which is an integer between 1 and 100,000. LIMIT= is optional, and the default is LIMIT=100000.

OFFSET=fred_offset

specifies the number of rows (time series observations) to skip before reading the time series observations from the FRED database. It is an optional nonnegative integer, and the default is OFFSET=0.

SORT=‘fred_sort’

specifies the ascending or descending order of time series observations. The valid order arguments are ‘asc’ (for ascending) and ‘desc’ (for descending). SORT= is optional, and the default is SORT=‘asc’.

UNITS=‘fred_units’

specifies the data value transformation. The valid units arguments are ‘lin’, ‘chg’, ‘ch1’, ‘pch’, ‘pc1’, ‘pca’, ‘cch’, ‘cca’, and ‘log’. It is an optional string, and the default is UNITS=‘lin’ (for no transformation). The details of the arguments and the corresponding formulas are presented in Table 39.6. When you specify UNITS='chg' and OUTPUT=1 (observation by real-time period), it is important to specify a date in the START= option that is later than the series observation start date, Obs_Start. Failure to do so forces the SASEFRED interface engine to change UNITS='chg' to UNITS='lin'.

VINTAGE=‘fred_vintage_date1,fred_vintage_date2,...,fred_vintage_dateN’

specifies one or more vintage dates in history. The fred_vintage_dates are represented in YYYY-MM-DD format and are used to download the data for a time series as it existed on that specific date in history. The dates in the list are separated by commas (no blanks are allowed). When requesting multiple vintage dates, specify OUTPUT=2 to retrieve all observations or OUTPUT=3 to retrieve only new or revised observations. The default setting is no vintage dates.

ArchivaL Federal Reserve Economic Data (ALFRED) enable you to retrieve vintage versions of economic data that were available on specific dates in history. To retrieve vintage versions of various time series, enter the following URL in your web browser:

http://alfred.stlouisfed.org/

To see a list of available vintage dates for each series, refer to the FRED documentation at the web page with the following URL:

http://api.stlouisfed.org/docs/fred/series_vintagedates.html

OUTPUT= 1 | 2 | 3 | 4

specifies the type of the file to be received from the FRED website. It is an optional integer value. You can specify the following fred_output_types:

1

specifies the type, Observations by Real-Time Period.

2

specifies the type, Observations by Vintage Date, All Observations.

3

specifies the type, Observations by Vintage Date, New and Revised Observations Only.

4

specifies the type, Observations, Initial Release Only.

Note: If OUTPUT=1 and UNITS='lin', then you must specify a START= date that is later than the series observation start date, Obs_Start. Note: If OUTPUT=3 or OUTPUT=4, then you must specify UNITS=’lin’.

FORMAT=fred_xmlformat

specifies the format of the file to be received from the FRED website. Although FRED can report data in many formats, the SASEFRED engine for 9.4 supports the XML format (default).

Table 39.5: FRED Frequency Codes

Frequency Code

Description

d

Displays data on a daily basis

w

Displays data on a weekly basis

bw

Displays data on a biweekly basis

m

Displays data on a monthly basis

q

Displays data on a quarterly basis

sa

Displays data on a semiannual basis

a

Displays data on an annual basis

wef

Displays data on a weekly (ending Friday) basis

weth

Displays data on a weekly (ending Thursday) basis

wew

Displays data on a weekly (ending Wednesday) basis

wetu

Displays data on a weekly (ending Tuesday) basis

wem

Displays data on a weekly (ending Monday) basis

wesu

Displays data on a weekly (ending Sunday) basis

wesa

Displays data on a weekly (ending Saturday) basis

bwew

Displays data on a biweekly (ending Wednesday) basis

bwem

Displays data on a biweekly (ending Monday) basis


Table 39.6: FRED Transformation UNITS Codes

Units Code

Description

Formula

chg

Change

$x_ t - x_{t-1}$

ch1

Change from year ago

$x_ t - x_{t-N}$

pch

Percent change

$(\frac{x_ t}{x_{t-1}} - 1) \times 100$

pc1

Percent change from year ago

$(\frac{x_ t}{x_{t-N}} - 1) \times 100$

pca

Compounded annual rate of change

$(\frac{x_ t}{x_{t-1}})^ N - 1) \times 100$

cch

Continuously compounded rate of change

$(ln(x_ t) - ln(x_{t-1})) \times 100$

cca

Continuously compounded annual rate of change

$((ln(x_ t) - ln(x_{t-1})) 100) \times N$

log

Natural log

$ln(x_ t)$

$x_ t$ is the value of series x at time period t. $N$ is the number of observations per year that differs by frequency: Daily $(N=260)$, Annual $(N=1)$, Monthly $(N=12)$, Quarterly $(N=4)$, Biweekly $(N=26)$, and Weekly $(N=52)$.