Specifying the URL= Option to Create SERIESS Data Set.

/*----------------------------------------------------------------

                   SAS SAMPLE LIBRARY

       Name: fredex08.sas
Description: Example program from SAS/ETS User's Guide,
             The SASEFRED Interface Engine
      Title: Specifying the URL= Option to Create SERIESS Data Set.

    Product: SAS/ETS Software
       Keys: FRED data extraction
      Procs: SASEFRED
      Notes: Read this before you run this sample.
             The sample data provided resides in the ets/sasmisc folder.
             Define a system environment variable,
             FRED, to the path of your  writeable folder containing
             the XFREDtpu.xml as your destination folder for FRED data.
             To assign a fileref to the external file to be processed,
             use the following form of the libname statement:

           libname fred sasefred "%sysget(FRED)"
              URL="https://api.stlouisfed.org/fred/release/series?release_id=51"
              APIKEY='<your FRED apikey>'
              ;
 ----------------------------------------------------------------*/

options validvarname=any
   sslcalistloc="/SASSecurityCertificateFramework/1.1/cacerts/trustedcerts.pem";

title 'Specifying the URL= Option to Create the SERIES Data Set';
libname _all_ clear;

libname fred2 sasefred "%sysget(FRED)"
   URL="https://api.stlouisfed.org/fred/release/series?release_id=51"
   APIKEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
   ;

data series2;
   set fred2.XFREDtpu;
run;

proc contents
   data=series2;
run;

%macro pri10nom(datname);
data lastob;
   set &datname nobs=last;
   last5=last-4;
   if last>10 then
      call symput('print5',last5);
   else
      call symput('print5',9);
run;
data getall10;
   set &datname(obs=5) &datname(firstobs=&print5);
run;
proc print data=getall10; run;
%mend pri10nom;

title3 "First 5/Last 5 Obs, SERIES2 Data Set";
%pri10nom(series2);