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 validvarname=any;

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

ObsdateBOPGS_BAL_SBOPGS_EXP_SBOPGS_IMP_SBOPG_BAL_UBOPG_EXP_UBOPG_IMP_U
12021-09-77095213039290134-103031143002246033
22021-10-66942227955294897-88071164954253025
32021-11-80153230642310795-103963157499261462
42021-12-80792235613316405-98430160406258836
52022-01-85565231087316652-99946149224249170
62022-02-87070235969323039-83863152154236017
72022-03-101914246646348560-116344181849298193
82022-04-85376254374339750-98762176115274876


Last updated: July 09, 2026