(View the complete code for this example.)
The following statements demonstrate how to use the URL= option to obtain the first 10 observations (LIMIT=10) of the REL3 data set for today’s date and how to create a permanent data set named REL3 in the MyLib SAS library:[22]
options validvarname=any;
title 'Specifying the URL= Option to Create the REL3 Data Set';
libname _all_ clear;
libname mylib "< path to your folder for data >";
libname fred3 sasefred "%sysget(FRED)"
debug=on
URL="https://api.stlouisfed.org/fred/releases?limit=10"
APIKEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
;
data mylib.rel3;
set fred3.XFREDtpu;
run;
proc print
data=mylib.rel3;
run;
proc contents
data=mylib.rel3;
run;
The returned data are stored in the XFREDTPU data set and are copied to the permanent data set named rel3.sas7bdat in the MyLib library. A side effect of the DATA step is the automatic creation of two SAS data sets, named release.sas7bdat and releases.sas7bdat, in the FRED3 library’s location. Hundreds of available releases could be returned for today, but the LIMIT=10 option obtains only the first 10 releases, as shown in Output 48.15.1.
Output 48.15.1: Specifying the URL= Option to Create the REL3 Data Set
| Specifying the URL= Option to Create the REL3 Data Set |
| Obs | releases_ORDINAL | release_ORDINAL | release_id | release_realtime_start | release_realtime_end | release_name | release_press_release | release_link | release_notes |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 9 | 2020-05-12 | 2020-05-12 | Advance Monthly Sales for Retail and Food Services | true | http://www.census.gov/retail/ | The U.S. Census Bureau conducts the Advance Monthly Retail Trade and Food Services Survey to provide an early estimate of monthly sales by kind of business for retail and food service firms located in the United States. Each month, questionnaires are mailed to a probability sample of approximately 4,700 employer firms selected from the larger Monthly Retail Trade Survey. Advance sales estimates are computed using a link relative estimator. For each detailed industry, we compute a ratio of current-to previous month weighted sales using data from units for which we have obtained usable responses for both the current and previous month. For each detailed industry, the advance total sales estimates for the current month is computed by multiplying this ratio by the preliminary sales estimate for the previous month (derived from the larger MRTS) at the appropriate industry level. Total estimates for broader industries are computed as the sum of the detailed industry estimates. The link relative estimate is used because imputation is not performed for most nonrespondents in MARTS. For a limited number of nonresponding companies that have influential effects on the estimates, sales may be estimated based on historical performance of that company. The monthly estimates are benchmarked to the annual survey estimates from the Annual Retail Trade Survey once available. The estimates are adjusted for seasonal variation and holiday and trading day differences. Additional information on MARTS and MRTS can be found on the Census Bureau website at: www.census.gov/retail. Description of the survey as provided by the Census, https://census.gov/retail/marts/www/marts_current.pdf |
| 2 | 1 | 2 | 10 | 2020-05-12 | 2020-05-12 | Consumer Price Index | true | http://www.bls.gov/cpi/ | |
| 3 | 1 | 3 | 11 | 2020-05-12 | 2020-05-12 | Employment Cost Index | true | http://www.bls.gov/ncs/ect/ | |
| 4 | 1 | 4 | 13 | 2020-05-12 | 2020-05-12 | G.17 Industrial Production and Capacity Utilization | true | http://www.federalreserve.gov/releases/g17/ | |
| 5 | 1 | 5 | 14 | 2020-05-12 | 2020-05-12 | G.19 Consumer Credit | true | http://www.federalreserve.gov/releases/g19/ | |
| 6 | 1 | 6 | 15 | 2020-05-12 | 2020-05-12 | G.5 Foreign Exchange Rates | true | http://www.federalreserve.gov/releases/g5/ | |
| 7 | 1 | 7 | 17 | 2020-05-12 | 2020-05-12 | H.10 Foreign Exchange Rates | true | http://www.federalreserve.gov/releases/h10/ | |
| 8 | 1 | 8 | 18 | 2020-05-12 | 2020-05-12 | H.15 Selected Interest Rates | true | http://www.federalreserve.gov/releases/h15/ | |
| 9 | 1 | 9 | 19 | 2020-05-12 | 2020-05-12 | H.3 Aggregate Reserves of Depository Institutions and the Monetary Base | true | http://www.federalreserve.gov/releases/h3/ | |
| 10 | 1 | 10 | 20 | 2020-05-12 | 2020-05-12 | H.4.1 Factors Affecting Reserve Balances | true | http://www.federalreserve.gov/releases/h41/ |
[22] Disclaimer: SAS may reference other websites or content or resources for use at Customer's sole discretion. SAS has no control over any websites or resources that are provided by companies or persons other than SAS. Customer acknowledges and agrees that SAS is not responsible for the availability or use of any such external sites or resources, and does not endorse any advertising, products, or other materials on or available from such websites or resources. Customer acknowledges and agrees that SAS is not liable for any loss or damage that may be incurred by Customer or its end users as a result of the availability or use of those external sites or resources, or as a result of any reliance placed by Customer or its end users on the completeness, accuracy, or existence of any advertising, products, or other materials on, or available from, such websites or resources.