SASEMOOD Interface Engine
Example 24.1 Retrieving Consumer Price Index Data from Moody’s Analytics Data Buffet
This example requests Consumer Price Index data (all items, total for United States) from the OECD Main Economic Indicators database. The MNEMONIC= option specifies the Moody’s data to retrieve, which in this example is OCMCPALTT01IXOBAM.IUSA. The FREQ= option requests monthly data. The range is specified using the START= and END= options. The OUTJSON= option names the JSON file and the SAS output data set that contains the time series data from the downloaded JSON file. The CONV= option specifies cubic conversion to the desired frequency. The SAS system option VALIDVARNAME=ANY allows for the special character '.' in the mnemonic code; the same mnemonic code is used to name the SAS variable’s series name in the SAS output data set.
The SAS code is shown after the next paragraph, and it is followed by the output, shown in Output 24.1.1, for the selected date range.
The SET statement reads observations from the input data set Moody.monCPI, and the DATA step stores them in a SAS data set named myMONCPI. When all the data are retrieved, they are placed in a SAS data set that is named by the OUT= option and that is located in the folder specified by the physical-name in the LIBNAME statement.
options;
title 'Request Consumer Price Index (Total - All Items - Index 2015-100)';
LIBNAME moody sasemood "%sysget(MOOD_DATA)"
mnemonic="OCMCPALTT01IXOBAM.IUSA"
user='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
pass='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
freq=monthly
conv=2
outjson=moncpi
start='2017-01-01'
end='2018-05-01'
format=json;
data myMONCPI;
set moody.moncpi;
run;
proc print data=myMONCPI; run;
Output 24.1.1: US Monthly CPI Data in OECD Main Economic Indicators Database
| Request Consumer Price Index (Total - All Items - Index 2015-100) |
| Obs | date | OCMCPALTT01IXOBAM.IUSA |
|---|---|---|
| 1 | 2017-01-31 | 102.827 |
| 2 | 2017-02-28 | 102.958 |
| 3 | 2017-03-31 | 102.828 |
| 4 | 2017-04-30 | 102.971 |
| 5 | 2017-05-31 | 102.915 |
| 6 | 2017-06-30 | 103.022 |
| 7 | 2017-07-31 | 103.085 |
| 8 | 2017-08-31 | 103.496 |
| 9 | 2017-09-30 | 103.978 |
| 10 | 2017-10-31 | 104.031 |
| 11 | 2017-11-30 | 104.352 |
| 12 | 2017-12-31 | 104.569 |
| 13 | 2018-01-31 | 104.978 |
| 14 | 2018-02-28 | 105.256 |
| 15 | 2018-03-31 | 105.230 |
| 16 | 2018-04-30 | 105.460 |
| 17 | 2018-05-31 | 105.748 |