(View the complete code for this example.)
This example shows how to use the ExtractFormulaHistory factlet to retrieve book value data for one company (in this case Exxon Mobil, or XOM) by using relative dates. The book value represents the proportional common equity divided by outstanding shares at the end of the company’s fiscal year. The relative date specifies the date as n periods ago based on the frequency (specified or implied); for example, DATES=0:-8:y returns data for the nine years prior to the most recently updated year.
options validvarname=any;
title 'Retrieve Book Value Data for Exxon Mobil (XOM) for the Last 9 Years';
libname _all_ clear;
libname xfsd sasexfsd "%sysget(FACTSET)"
debug=on
factlet=ExtractFormulaHistory
ids='xom'
items='ff_bps'
dates='0:-8:y'
format=sml
outXml=fsdex03
automap=replace
mapref=MyMap
xmlmap="%sysget(FACTSET)fsdex03.map"
orientation=eti
user='XXXXXXXXXXXXXXXX'
pass='XXXXXXXXXXXXXXXX';
data bookRelative; set xfsd.fsdex03; run;
proc print data=bookRelative; run;
Output 56.8.1: Book Value Data for Exxon Mobil for the Last 9 Years
| Retrieve Book Value Data for Exxon Mobil (XOM) for the Last 9 Years |
| Obs | FQL_Entity | date | ff_bps |
|---|---|---|---|
| 1 | xom | 12-31-2004 | 15.8969 |
| 2 | xom | 12-31-2005 | 18.1291 |
| 3 | xom | 12-31-2006 | 19.8715 |
| 4 | xom | 12-31-2007 | 22.6239 |
| 5 | xom | 12-31-2008 | 22.7020 |
| 6 | xom | 12-31-2009 | 23.3910 |
| 7 | xom | 12-31-2010 | 29.4917 |
| 8 | xom | 12-31-2011 | 32.6143 |
| 9 | xom | 12-31-2012 | 36.8421 |