(View the complete code for this example.)
This example shows how to use the ExtractBenchmarkDetail factlet to retrieve the holdings for the Standard & Poor’s (S&P) 500 (ID=’sp50’) and display the P_PRICE data that correspond to each holding. For brevity, only a subset of the output (the first 10 holdings) is displayed.
options validvarname=any;
title 'Retrieve Benchmark Data for Top Ten Holdings, CUTOFF=10';
libname _all_ clear;
libname fsd sasexfsd "%sysget(FACTSET)"
debug=on
factlet=ExtractBenchmarkDetail
ids='sp50'
items='p_price,proper_name'
dates='20130320'
cutoff=10
format=sml
outXml=fsdex12
automap=replace
mapref=MyMap
xmlmap="%sysget(FACTSET)fsdex12.map"
orientation=eti
user='XXXXXXXXXXXXXXXX'
pass='XXXXXXXXXXXXXXXX';
data bench;
set fsd.fsdex12;
run;
proc print
data=bench;
run;
The CUTOFF= option limits the output to the number of holdings that are specified. This example uses CUTOFF=10 to print the top 10 holdings. If you omit the CUTOFF= option, all 500 holdings are reported.
Output 56.11.1: Retrieving Benchmark Data for Top 10 Holdings in the S&P 500 Index
| Retrieve Benchmark Data for Top Ten Holdings, CUTOFF=10 |
| Obs | FQL_ENTITY | date | SECURITY_ID | Weight | p_price | proper_name |
|---|---|---|---|---|---|---|
| 1 | SP50 | . | 41308610 | . | 44.4800 | Harman International Industries Inc. |
| 2 | SP50 | . | 80589M10 | . | 49.5100 | SCANA Corp. |
| 3 | SP50 | . | 50242410 | . | 81.2100 | L-3 Communications Holdings Inc. |
| 4 | SP50 | . | 91301710 | . | 93.4500 | United Technologies Corp. |
| 5 | SP50 | . | 97665710 | . | 41.4400 | Wisconsin Energy Corp. |
| 6 | SP50 | . | 00130H10 | . | 12.6800 | AES Corp. |
| 7 | SP50 | . | 31190010 | . | 51.4700 | Fastenal Co. |
| 8 | SP50 | . | 20911510 | . | 59.1600 | Consolidated Edison Inc. |
| 9 | SP50 | . | 53983010 | . | 92.2400 | Lockheed Martin Corp. |
| 10 | SP50 | 12-31-2000 | 17290810 | . | 43.8800 | Cintas Corp. |