*! version 6.0.0   11feb1999 statalist distribution
program define labsave5
	version 6

						/* locate the filename */
	local hold0 `"`0'"'
	tokenize `"`0'"'
	local i 1
	while "``i''" != "using" & "``i''" != "using," & "``i''" != ",using" {
		local i = `i' + 1
	}
	local i = `i' + 1
	local file ``i''
	local file : subinstr local file "," ""

	if !index("`file'", ".") { local file = "`file'" + ".do" }

	label save `hold0'			/* save in 6.0 format */

						/* process to 5.0 format */
	preserve

	drop _all

	qui infix str80 labstr 1-80 using `file'
	erase `file'

	qui gen byte k = index(labstr, "\`")
	qui replace labstr = substr(labstr, 1, k-1) + substr(labstr, k+1, .)
	qui replace k = index(labstr, "'")
	qui replace labstr = substr(labstr, 1, k-1) + substr(labstr, k+1, .)

	qui outfile labstr using `file', noquote

	restore

end