|The SASECRSP Interface Engine|
It is possible to specify both individual range restrictions with an INSET and a global date range restriction via the RANGE= option on the LIBNAME statement. In such cases, only observations that satisfy both date range restrictions are returned. The effective range restriction becomes the intersection of the two specified range restrictions. If this intersection is empty, no observations are returned.
This example extracts data for two companies, IBM and Microsoft. Each company has an individual range restriction specified in the inset. Furthermore, a global range restriction is set by the RANGE= option on the LIBNAME statement. As a result the effective date range restriction for IBM becomes August 1, 1999, to February 1, 2000, and the effective date range restriction for Microsoft becomes January 1, 2001, to April 21, 2002.
data two_companies; gvkey=6066; date1=19800101; date2=20000201; output; gvkey=12141; date1=20010101; date2=20051231; output; run; libname _all_ clear; libname mylib sasecrsp "%sysget(CRSP_CST)" SETID=200 INSET='two_companies,gvkey,gvkey,date1,date2' RANGE='19990801-20020421'; title1 'Two Companies, Two Range Selections'; title2 'Global RANGE Statement Used With Individual Inset Ranges'; title3 'Results Show Intersection of Both Range Restrictions'; proc sql; select prcc.gvkey,prcc.caldt,prcc,ern from mylib.prcc as prcc, mylib.ern as ern where prcc.caldt = ern.caldt and prcc.gvkey = ern.gvkey; quit;
Output 35.11.1 shows the combined effect of both INSET and RANGE date restrictions on the closing prices and earnings per share for IBM and Microsoft.
|Two Companies, Two Range Selections|
|Global RANGE Statement Used With Individual Inset Ranges|
|Results Show Intersection of Both Range Restrictions|
|Closing Price||Earnings Per Share|
For more about using the SQL procedure, see the chapter on SQL in Base SAS Procedures Guide.
Copyright © SAS Institute, Inc. All Rights Reserved.