To specify the parts of the database that you want to access, you supply two things: the list of IDs for the companies or securities that you want to access, and the list of data items that you want to retrieve.
When accessing company or security data, use the ExtractFormulaHistory factlet. Use the IDS= option to specify the list of IDs that identify the companies that you want to access by specifying the entity ID (such as the ticker symbol) for each company.
For example, the following statements access the FactSet Fundamentals database for monthly sales data (ff_sales) and the Prices database for pricing data (p_price) for IBM (ID=’ibm’) and for FactSet Research Systems (ID=’fds’). To include both IDs in the same request, specify IDS=’ibm,fds’; to include both data items in the same request, specify ITEMS=’p_price,ff_sales’, as follows:
LIBNAME myLib sasexfsd "%sysget(FACTSET)" FACTLET=ExtractFormulaHistory FORMAT=sml OUTXML=gstart1 AUTOMAP=replace MAPREF=MyMap XMLMAP="%sysget(FACTSET)gstart1.map" IDS='ibm,fds' ITEMS='p_price,ff_sales' DATES='20110130:20110631:m' ORIENTATION=eti user='XXXXXXXXXXXXXXXX' pass='XXXXXXXXXXXXXXXX'; ; data company_pvol; set myLib.gstart1; run; proc contents data=company_pvol; run; proc print data=company_pvol; run;
Figure 44.1: Getting Started with ExtractFormulaHistory: Company_pvol
Obs | FQL_ENTITY | date | p_price | ff_sales |
---|---|---|---|---|
1 | ibm | 01-31-2011 | 162.000 | 99870.00 |
2 | ibm | 02-28-2011 | 161.880 | 99870.00 |
3 | ibm | 03-31-2011 | 163.070 | 99870.00 |
4 | ibm | 04-30-2011 | 170.580 | 99870.00 |
5 | ibm | 05-31-2011 | 168.930 | 99870.00 |
6 | ibm | 06-30-2011 | 171.550 | 99870.00 |
7 | fds | 01-31-2011 | 100.800 | 641.06 |
8 | fds | 02-28-2011 | 104.880 | 641.06 |
9 | fds | 03-31-2011 | 104.730 | 641.06 |
10 | fds | 04-30-2011 | 109.410 | 641.06 |
11 | fds | 05-31-2011 | 110.860 | 641.06 |
12 | fds | 06-30-2011 | 102.320 | 641.06 |
The SASEXFSD engine supports only the SAS XML (SML) format and the ETI orientation. The XML data that are returned from the FactSet OnDemand service are placed in a file specified by the OUTXML= option. The XML map that is automatically created is assigned the full pathname specified by the XMLMAP= option, and the fileref that is used for the map assignment is specified by the MAPREF= option. In the preceding example, the SASEXFSD engine uses the MAPREF= and XMLMAP= options in the FILENAME statement to assign a filename:
FILENAME MyMap "U:\factset\test\gstart1.map";
You can use the MAPREF= and XMLMAP= options to control where the map resides, what you name the map, and how you refer to it with a fileref. You can use the OUTXML= option to name your XML data file; this is described in the section SAS OUTXML File. This data file is placed in the folder designated by ‘physical-name’, which is described in the section The LIBNAME libref SASEXFSD Statement. You can refer to your data by using the myLib libref in your SASEXFSD LIBNAME statement. In the preceding program, this statement appears inside the DATA step in the SET statement, which names the input data set myLib.gstart1 and causes the reading of the GSTART1.xml file to be input and stored in the SAS data set Company_pvol.
The Company_pvol data set contains two time series variables (data items), p_price and ff_sales, as specified in the ITEMS= option, and the observation range is controlled by the DATES= option. The prefixes, ff_ and p_, are the database designators for the FactSet Fundamentals and Prices databases, respectively, as shown in Table 44.2. The Company_pvol data set contains observations that range from January 30, 2011, to June 31, 2011, as specified in the DATES= option. The frequency of the data is monthly, as specified by the ‘m’ at the end of the DATES= option. Figure 44.1 shows the results.
To specify the list of data items that you want to retrieve, use the ITEMS= option. This option accepts a string, enclosed in single quotation marks, that denotes a list of data items that you are selecting for the resulting SAS data set. The data item names are separated by commas, so valid item names cannot contain embedded commas or quotation marks. The prefix in each data item name designates the data source as defined in the Prefix column of Table 44.2.
After the libref is assigned by the LIBNAME statement, the database is opened. The selected data are organized into group entities (BY groups) that are sorted by date. In Figure 44.1, the tickers are the BY groups, and within each ticker, the observations are sorted by the time ID variable DATE.
You can also use the SAS DATA step to perform further subsetting and to store the resulting time series in a SAS data set.
The SASEXFSD engine is supported on 64-bit Windows platforms.