Available here: https://wrds-web.wharton.upenn.edu/wrds/tools/variable.cfm
cusip:
res <- dbSendQuery(wrds, "select distinct table_schema
from information_schema.tables
where table_type ='VIEW'
or table_type ='FOREIGN TABLE'
order by table_schema")
list_libraries <- dbFetch(res, n=-1)
dbClearResult(res)
list_libraries %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
list_variables_crsp_msf <- dbSendQuery(wrds, "select column_name
from information_schema.columns
where table_schema='crsp'
and table_name='msf'
order by column_name") %>%
dbFetch
list_variables_crsp_msf %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
list_variables_comp_funda <- dbSendQuery(wrds, "select column_name
from information_schema.columns
where table_schema='comp'
and table_name='funda'
order by column_name") %>%
dbFetch
list_variables_comp_funda %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
list_variables_comp_funda_fncd <- dbSendQuery(wrds, "select column_name
from information_schema.columns
where table_schema='comp'
and table_name='funda_fncd'
order by column_name") %>%
dbFetch
list_variables_comp_funda_fncd %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
compustat_AAPL <- dbSendQuery(wrds, "select *
from comp.funda
where tic = 'AAPL' and DATAFMT='STD' and POPSRC='D' and CONSOL='C'
and FIC='USA'") %>%
dbFetch
crsp_AAPL <- dbSendQuery(wrds, "select cusip, permno, permco, date, prc, vol
from crsp.msf
where cusip='03783310' and date between '1975-01-01' and '2018-12-31'") %>%
dbFetch
compustat <- dbSendQuery(wrds, "select gvkey, conm, datadate, fyear, tic, emp, at, revt, act, xsga, cogs, ppegt, ppent, xrd, ebitda, ebit
from comp.funda
where FYEAR='2017' and DATAFMT='STD' and POPSRC='D' and CONSOL='C'
and FIC='USA'") %>%
dbFetch
compustat %>%
select(emp, at, revt, act, xsga, cogs, ppegt, ppent, xrd, ebitda, ebit) %>%
summarise_all(funs(sum(., na.rm = TRUE))) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
Therefore:
List of variables for Apple:
Apple has approximately 5 billion shares
$ 156 dollar per shares. Therefore it’s 5*156 = 780 Billion:
list.variables <- c("fyear", "emp", "at", "revt", "act", "xsga", "cogs",
"ppegt", "ppent", "xrd", "ebitda", "ebit", "cshfd",
"epspi", "epspx", "mkvalt", "cshi", "csho")
compustat_AAPL %>%
select(list.variables) %>%
filter(fyear >= 2016) %>%
t()
# [,1] [,2] [,3] [,4] [,5]
# fyear 2016.000 2017.000 2018.000 2019.000 2020.00
# emp 116.000 123.000 132.000 137.000 147.00
# at 321686.000 375319.000 365725.000 338516.000 323888.00
# revt 215091.000 229234.000 265359.000 260174.000 274515.00
# act 106869.000 128645.000 131339.000 162819.000 143713.00
# xsga 24239.000 26842.000 30941.000 34462.000 38668.00
# cogs 121576.000 131648.000 152853.000 149235.000 158503.00
# ppegt 61245.000 75076.000 90403.000 95957.000 112096.00
# ppent 27010.000 33783.000 41304.000 37378.000 45336.00
# xrd 10045.000 11581.000 14236.000 16217.000 18752.00
# ebitda 69276.000 70744.000 81565.000 76477.000 77344.00
# ebit 59476.000 61344.000 70662.000 63930.000 66288.00
# cshfd 5500.281 5251.692 5000.109 4648.913 17528.21
# epspi 8.350 9.270 12.010 11.970 3.31
# epspx 8.350 9.270 12.010 11.970 3.31
# mkvalt 603253.566 790050.098 1073390.540 995151.567 1966078.92
# cshi 5336.166 5126.201 4754.986 4443.236 16976.76
# csho 5336.166 5126.201 4754.986 4443.236 16976.76
compustat_variable_names %>%
filter(grepl("Share", V2)) %>%
arrange(V2) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
compustat_variable_names %>%
filter(grepl("Revenue", V2)) %>%
arrange(V2) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}