Previous Page | Next Page

The SASECRSP Interface Engine

Example 35.10 Using Different Types of Range Restrictions in the INSET

You can specify both calendar and fiscal date range restrictions with the INSET= option. This example shows how to use both types of date range restrictions.

Two INSETs, nearly identical except for the type of their date range restriction, are used for accessing the same database. Despite the many similarities, the different date range restriction types result in dissimilar output.

Note that the specification of the datetype in the INSET= option for comp_calendar is not required. The datetype default is the calendar type.

   data comp_fiscal;

      /* Crude Petroleum & Natural Gas */
      compkey=2416;
      begdate=19860101; enddate=19861231;
      datetype='fiscal';
      output;

      /* Commercial Intertech */
      compkey=3248;
      begdate=19940101; enddate=19941231;
      datetype='fiscal';
      output;
   run;

   data comp_calendar;

      /* Crude Petroleum & Natural Gas */
      compkey=2416;
      begdate=19860101; enddate=19861231;
      datetype='calendar';   output;

      /* Commercial Intertech */
      compkey=3248;
      begdate=19940101; enddate=19941231;
      datetype='calendar';
      output;
  run;
libname _all_ clear;
libname fisclib sasecrsp "%sysget(CRSP_CST)"
        SETID=200
        INSET='comp_fiscal,compkey,gvkey,begdate,enddate,datetype';

libname callib sasecrsp "%sysget(CRSP_CST)"
        SETID=200
        INSET='comp_calendar,compkey,gvkey,begdate,enddate,datetype';
title1 'Quarterly Period Descriptors';
title2 'Using the Fiscal Date Range';
proc print data=fisclib.qperdes(drop = peftnt1 peftnt2 peftnt3 peftnt4
                                       peftnt5 peftnt6 peftnt7 peftnt8
                                       candxc flowcd spbond spdebt sppaper);
run;

Output 35.10.1 shows quarterly period descriptors for the 1986 and 1994 fiscal years.

Output 35.10.1 Using Inset with Fiscal Date Range
Quarterly Period Descriptors
Using the Fiscal Date Range

Obs GVKEY CRSPDT RCALDT FISCALDT DATYR DATQTR FISCYR CALYR CALQTR UPCODE SRCDOC SPBOND SPDEBT SPPAPER SPRANK MAJIND INDIND REPDT FLOWCD CANDXC PEFTNT1 PEFTNT2 PEFTNT3 PEFTNT4 PEFTNT5 PEFTNT6 PEFTNT7 PEFTNT8
1 2416 242 19860630 19860331 1986 1 3 1986 2 3 53 0 0 0 17 0 0 0 1 0                
2 2416 243 19860930 19860630 1986 2 3 1986 3 3 53 0 0 0 18 0 0 0 1 0                
3 2416 244 19861231 19860930 1986 3 3 1986 4 3 53 0 0 0 18 0 0 0 1 0                
4 2416 245 19870331 19861231 1986 4 3 1987 1 3 53 0 0 0 21 0 0 0 1 0                
5 3248 274 19940131 19940331 1994 1 10 1993 4 3 53 0 0 0 16 0 0 1994054 7 0                
6 3248 275 19940429 19940630 1994 2 10 1994 1 3 53 0 0 0 16 0 0 1994146 7 0                
7 3248 276 19940729 19940930 1994 3 10 1994 2 3 53 0 0 0 16 0 0 1994236 7 0                
8 3248 277 19941031 19941230 1994 4 10 1994 3 3 53 0 0 0 16 0 0 1994349 7 0                

The next PRINT procedure uses the calendar datetype in its INSET= option instead of the fiscal datetype, producing different results for the Crude Petroleum and Natural Gas Company when the report is based on calendar dates instead of fiscal dates. The differences shown in observations 1 through 4 are due to Crude Petroleum and Natural Gas Company’s fiscal year ending in March instead of December.

Since Commercial Intertech does not shift its fiscal year, but uses a fiscal year ending in December, the fiscal report and the calendar report match exactly for the company’s corresponding observations 5 through 8 in Output 35.10.1 and Output 35.10.2 respectively.

title1 'Quarterly Period Descriptors';
title2 'Using the Calendar Date Range';
proc print data=callib.qperdes(drop = peftnt1 peftnt2 peftnt3 peftnt4
                                      peftnt5 peftnt6 peftnt7 peftnt8
                                      candxc flowcd spbond spdebt sppaper);
run;

Output 35.10.2 shows quarterly period descriptors for the designated calendar date range.

Output 35.10.2 Using Inset with Calendar Date Range
Quarterly Period Descriptors
Using the Calendar Date Range

Obs GVKEY CRSPDT RCALDT FISCALDT DATYR DATQTR FISCYR CALYR CALQTR UPCODE SRCDOC SPBOND SPDEBT SPPAPER SPRANK MAJIND INDIND REPDT FLOWCD CANDXC PEFTNT1 PEFTNT2 PEFTNT3 PEFTNT4 PEFTNT5 PEFTNT6 PEFTNT7 PEFTNT8
1 2416 241 19860331 19851231 1985 4 3 1986 1 3 53 0 0 0 17 0 0 0 1 0                
2 2416 242 19860630 19860331 1986 1 3 1986 2 3 53 0 0 0 17 0 0 0 1 0                
3 2416 243 19860930 19860630 1986 2 3 1986 3 3 53 0 0 0 18 0 0 0 1 0                
4 2416 244 19861231 19860930 1986 3 3 1986 4 3 53 0 0 0 18 0 0 0 1 0                
5 3248 274 19940131 19940331 1994 1 10 1993 4 3 53 0 0 0 16 0 0 1994054 7 0                
6 3248 275 19940429 19940630 1994 2 10 1994 1 3 53 0 0 0 16 0 0 1994146 7 0                
7 3248 276 19940729 19940930 1994 3 10 1994 2 3 53 0 0 0 16 0 0 1994236 7 0                
8 3248 277 19941031 19941230 1994 4 10 1994 3 3 53 0 0 0 16 0 0 1994349 7 0                

Fiscal date range restrictions are valid only for fiscal members and can be used in either the INSET= option or the RANGE= option. Use calendar date ranges for nonfiscal members. Note:Fiscal date ranges are ignored when used with nonfiscal members.

Previous Page | Next Page | Top of Page