SEC common shares outstanding

Category : Uncategorized

SEC common shares outstanding

Please make sure you have the most updated mfd_dm, mfd_ta and mfd_tex packages for Stata installed for this post.

*
net from "http://www.researchforprofit.com/stata/mfd_dm"
net from "http://www.researchforprofit.com/stata/mfd_ta"
net from "http://www.researchforprofit.com/stata/mfd_tex"
* click on the blue mfd_dm package and then "click here to install" 
*

In this post, we will be downloading historic common shares outstanding for Apple Inc. SEC provides financial reports of public companies through Edgar On-line. fetchedgarxml downloads financial reports such as 10-K or 10-Q. You can even download form 4.

In this example, we will focus on historic common shares outstanding for Apple Inc. for the past 11 quarters.

*

clear all
cd "/Users/mfd/Desktop"

forval aa=1/11 {
	di "`aa'"
	qui: {
		mfd_dm_SEC_filings AAPL, filing("10-Q")
		mfd_dm_SEC_xml `aa'
		keep if item=="CommonStockSharesOutstanding"
		if (`aa'!=1) append using CommonStockSharesOutstanding.dta
		save CommonStockSharesOutstanding.dta, replace
	}
}
gen date=date(substr(contextRef,strpos(contextRef,"_20")+1,8),"YMD")
drop item unitRef decimals contextRef id
format date %td
sort date
duplicates drop date, force

gen change=amount-amount[_n-1]
format change %18.2fc
save AAPL.dta, replace
*

AAPL shares

Net Income

*
clear all
cd "/Users/mfd/Desktop"

local search_item="netincomeloss"
local file="140118_netincome.dta"

foreach bb in "AAPL" "GOOG" "MSFT" "AMZN" "XOM" "AA" {
	forval aa=1/12 {
		di "`bb': `aa'"
		qui: {
			mfd_dm_SEC_filings `bb', filing("10-Q")
			capture: mfd_dm_SEC_xml `aa'
			if (_rc==0) {
				if (_N>0) {
					keep if lower(item)=="`search_item'"
					gen Symbol="`bb'"
					capture: append using `file'
					save `file', replace
				}
			}
		}
	}
	forval aa=1/5 {
		di "`bb': `aa'"
		qui: {
			mfd_dm_SEC_filings `bb', filing("10-K")
			capture: mfd_dm_SEC_xml `aa'
			if (_rc==0) {
				if (_N>0) {
					keep if lower(item)=="`search_item'"
					gen Symbol="`bb'"
					capture: append using `file'
					save `file', replace
				}
			}
		}
	}
}

use "140118_netincome.dta", clear
replace contextRef=subinstr(contextRef,"--","-",.)
replace contextRef=subinstr(contextRef,"--","-",.)
replace contextRef=subinstr(contextRef,"--","-",.)

capture: split contextRef, parse("_") 
drop if contextRef7!=""

gen date=date(contextRef5,"YMD")
format %td date
drop if date==.

capture: split contextRef2, parse("-") 
drop item contextRef unitRef decimals id contextRef1 contextRef2 contextRef3 contextRef5 contextRef6 contextRef7 contextRef21 contextRef22

order Symbol date contextRef4 contextRef23 amount
duplicates drop
destring contextRef4, replace force
sort Symbol date contextRef4

rename contextRef4 period
rename contextRef23 filing
gen filing_type=substr(filing,1,1)
gen filing_order=substr(filing,2,.)
drop filing
destring filing_order, replace force
capture: drop contextRef*
*