(View the complete code for this example.)
The following statements demonstrate how to use the URL= option to obtain the first 10 sources (LIMIT=10) for the SOURCES6 data set for today’s date and how to create a permanent data set named SOURCES6 in the MyLib SAS library:[21]
options validvarname=any;
title 'Specifying the URL= Option to Create the SOURCES6 Data Set';
libname _all_ clear;
libname mylib "< path to your folder for data >";
libname fred6 sasefred "%sysget(FRED)"
debug=on
URL="https://api.stlouisfed.org/fred/sources?limit=10"
APIKEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
;
data mylib.sources6;
set fred6.XFREDtpu;
run;
proc print
data=mylib.sources6;
run;
proc contents
data=mylib.sources6;
run;
The returned data are stored in the XFREDTPU data set and are copied to the permanent data set named sources6.sas7bdat in the MyLib library. A side effect of the DATA step is the automatic creation of two SAS data sets, named source.sas7bdat and sources.sas7bdat, in the FRED6 library’s location. Many sources could be returned for today’s date, but the LIMIT=10 option obtains only the first 10 sources, as shown in Output 48.14.1.
Output 48.14.1: Specifying the URL= Option to Create the SOURCES6 Data Set
| Specifying the URL= Option to Create the SOURCES6 Data Set |
| Obs | sources_ORDINAL | source_ORDINAL | source_id | source_realtime_start | source_realtime_end | source_name | source_link |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 2020-05-12 | 2020-05-12 | Board of Governors of the Federal Reserve System (US) | http://www.federalreserve.gov/ |
| 2 | 1 | 2 | 3 | 2020-05-12 | 2020-05-12 | Federal Reserve Bank of Philadelphia | https://www.philadelphiafed.org/ |
| 3 | 1 | 3 | 4 | 2020-05-12 | 2020-05-12 | Federal Reserve Bank of St. Louis | http://www.stlouisfed.org/ |
| 4 | 1 | 4 | 6 | 2020-05-12 | 2020-05-12 | Federal Financial Institutions Examination Council (US) | http://www.ffiec.gov/ |
| 5 | 1 | 5 | 11 | 2020-05-12 | 2020-05-12 | Dow Jones & Company | http://www.dowjones.com |
| 6 | 1 | 6 | 14 | 2020-05-12 | 2020-05-12 | University of Michigan | https://www.umich.edu/ |
| 7 | 1 | 7 | 15 | 2020-05-12 | 2020-05-12 | Council of Economic Advisers (US) | https://www.whitehouse.gov/cea/ |
| 8 | 1 | 8 | 16 | 2020-05-12 | 2020-05-12 | U.S. Office of Management and Budget | https://www.whitehouse.gov/omb/ |
| 9 | 1 | 9 | 17 | 2020-05-12 | 2020-05-12 | U.S. Congressional Budget Office | http://www.cbo.gov/ |
| 10 | 1 | 10 | 18 | 2020-05-12 | 2020-05-12 | U.S. Bureau of Economic Analysis | http://www.bea.gov/ |
[21] 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.