SEC Edgar: Symbol => CIK (mfd_dm_SEC_CIK)

Category : Uncategorized

SEC Edgar: Symbol => CIK (mfd_dm_SEC_CIK)

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" 
*
*
clear all
cd "/users/mfd/desktop"
use "http://researchforprofit.com/data_public/profiles.dta", clear
levelsof Symbol, local(tickers)
mfd_dm_SEC_CIK `tickers'
* THE RESULTING DATASET IS AVAILABLE AT THE FOLLOWING LINK
use "http://researchforprofit.com/data_public/symbol_to_cik.dta", clear
*

ADO

*
program define mfd_dm_SEC_CIK, rclass
	
	version 10.0
	
	syntax anything(name=tickers)

	qui: {	
		foreach ticker in `tickers' {
			clear
			mata: get_CIK ("`ticker'")
			gen Symbol="`ticker'"
			compress
			capture: append using temp0000000000001.dta
			save temp0000000000001.dta, replace
			noi: di "CIK for `ticker' is: " cik[1]
		}
		erase temp0000000000001.dta
		sort Symbol
		order Symbol cik
	}
	
end



mata:
	void get_CIK (string scalar symbol)
	{
		icerik = file_get_contents("http://researchforprofit.com/posts/stata_edgar_cik.php?symbol=" + symbol)

		st_addvar("str244", "cik")
		st_addobs(1)
		st_sstore(.,"cik",icerik)
	}

	string file_get_contents (string scalar raw)
	{
		fh = fopen(raw, "r")
		raw=""
		while ((line=fget(fh))!=J(0,0,"")) {
			raw=raw+line
		}
		fclose(fh)
		return (raw)
	}
		
end
*