The SASECRSP Interface Engine

Using the INSET= Option

The following examples illustrate the use of the INSET= option.

Basic INSET= Option Use: Providing a List of PERMNOs

This example uses the INSET= option to extract monthly data for a portfolio of three companies. No date range restriction is used.

  data testin1;
     permno = 10107; output;
     permno = 12490; output;
     permno = 14322; output;

  LIBNAME mstk sasecrsp 'physical-name'

  proc print data=mstk.stkhead (keep=permno permco begdt enddt hcomnam htick);

General Use of the INSET= Option to Specify Lists of Keys

This example illustrates the use of the INSET= option to select a few index series from the CRSP Indices data, and securities from the CRSP US Stock data. The libref ind2 is used for accessing the CRSP Indices data by using the two specified INDNO keys. The libref sec3 is used to access the CRSP US Stock data by using the three specified TICKER keys. Note the use of shorthand in specifying the INSET= option. The date1field and the date2field, and datetype arguments are all omitted, so the default of no range restriction applies (though the range restriction set by the RANGE= option in the LIBNAME statement still applies). For more information, including sample output, see Example 38.4

  data indices;
      indno=1000000; output;  /* NYSE Value-Weighted Market Index */
      indno=1000001; output;  /* NYSE Equal-Weighted Market Index */

  libname ind2 sasecrsp "%sysget(CRSP_MSTK)" setid=420
      inset='indices,INDNO,INDNO' range='19990101-19990401';

  title2 'Total Returns for NYSE Value- and Equal-Weighted Market Indices';
  proc print data=ind2.tret label;

  data securities;
      ticker='BAC'; output;  /* Bank of America */
      ticker='DUK'; output;  /* Duke Energy */
      ticker='GSK'; output;  /* GlaxoSmithKline */

  libname sec3 sasecrsp "%sysget(CRSP_MSTK)" setid=20

  title2 'PERMNOs and General Header Info of Selected TICKERs';
  proc print data=sec3.stkhead (keep=permno htick htsymbol) label;

  title3 'Average Price for Bank of America, Duke and GlaxoSmithKline';
  proc print data=sec3.prc label; run;

Key-Specific Date Range Restriction with the INSET= Option

Suppose you not only want to select keys with your INSET= option, but you also want to specify a date range restriction for each key individually. The following statements show how to do this. Again, shorthand enables you to omit the date1field and date2field arguments. The dates that are provided default to a calendar interpretation. For more information, including the sample output, see Example 38.5.

  title2 'INSET=testin2 uses date ranges along with PERMNOs:';
  title3 '10107, 12490, 14322, 25788';
  title4 'Begin dates and end dates for each permno are used in the INSET';

  data testin2;
      permno = 10107; date1 = 19980731; date2 = 19981231; output;
      permno = 12490; date1 = 19970101; date2 = 19971231; output;
      permno = 14322; date1 = 19950731; date2 = 19960131; output;
      permno = 25778; date1 = 19950101; date2 = 19950331; output;

  libname mstk2 sasecrsp "%sysget(CRSP_MSTK)" setid=20

  data b;
      set mstk2.prc;

  proc print data=b;