* _fileext, version 1.0
* 26 Oct 2017
* Doug Hemken, Social Science Computing Cooperative

program define _fileext, rclass
	syntax using/
	local check: subinstr local using "." "", all
	local dots = length("`using'") - length("`check'")
	if `dots' {
		local undot: subinstr local using "." " ", all
		local wc : word count `undot'
		local extension: word `wc' of `undot'
	}
	else {
		local extension
		}
	return local extension "`extension'"
end