SASEUSCB Interface Engine
Example 25.3 Retrieving International Trade in Goods and Services (FTD) Data for All Data Types
This example shows how to retrieve International Trade in Goods and Services (FTD) data from the US Census Bureau website. You can view these data at the following web page:
https://www.census.gov/econ/currentdata/dbsearch?programCode=FTD
The following SASEUSCB LIBNAME statement specifies the libref (USCB), followed by the engine name (SASEUSCB) and the physical path where the retrieved USCB data are to be stored. The SETNAME= option specifies the name of the data set to retrieve data from. In this example, SETNAME=EITS_FTD requests data from the International Trade in Goods and Services data set. The USER= option specifies your unique USCB API key. Without a user API key (which you can obtain free of charge), you cannot retrieve data from the US Census Bureau. The FOR='US:*' option requests data for all of the United States. The DATATYPE= option is omitted because the example includes all data types in the retrieved data. The CATEGORY= option is also omitted because the example includes all categories in the retrieved data. See Table 12 for a complete list of available categories, and see Table 13 for a complete list of available data types. The OUTJSON=USCBEX03 option names the file where the JSON data are stored. The output data set is created by using the name that is specified in the OUTJSON= option and placed in the folder that is specified in the SASEUSCB LIBNAME statement. The date range of the data starts with September 2021, as specified by the STARTDATE='2021-09' option. The ENDDATE='2022-04' option specifies the last month to include in the range of data to retrieve (April 2022). The FORMAT=JSON option specifies that the data are to be retrieved in the JSON format. Output 25.3.1 shows the FTD data that are retrieved. Time series whose names end in '_S' contain seasonal data, and time series whose names end in '_U' contain nonseasonal data.
options;
title 'Retrieve International Trade in Goods and Services Data';
libname uscb saseuscb "%sysget(USCB)"
user='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
setname=EITS_FTD
for='US:*'
startdate='2021-09'
enddate='2022-04'
outjson=uscbex03
format=json;
data myFT2D;
set uscb.uscbex03 ;
run;
proc contents data=myFT2D; run;
proc print data=myFT2D; run;
Output 25.3.1: Retrieve International Trade in Goods and Services (FTD) Data
| Retrieve International Trade in Goods and Services Data |
| Obs | date | BOPGS_BAL_S | BOPGS_EXP_S | BOPGS_IMP_S | BOPG_BAL_U | BOPG_EXP_U | BOPG_IMP_U |
|---|---|---|---|---|---|---|---|
| 1 | 2021-09 | -77095 | 213039 | 290134 | -103031 | 143002 | 246033 |
| 2 | 2021-10 | -66942 | 227955 | 294897 | -88071 | 164954 | 253025 |
| 3 | 2021-11 | -80153 | 230642 | 310795 | -103963 | 157499 | 261462 |
| 4 | 2021-12 | -80792 | 235613 | 316405 | -98430 | 160406 | 258836 |
| 5 | 2022-01 | -85565 | 231087 | 316652 | -99946 | 149224 | 249170 |
| 6 | 2022-02 | -87070 | 235969 | 323039 | -83863 | 152154 | 236017 |
| 7 | 2022-03 | -101914 | 246646 | 348560 | -116344 | 181849 | 298193 |
| 8 | 2022-04 | -85376 | 254374 | 339750 | -98762 | 176115 | 274876 |