*! version 1.0.0  08Feb1999
program define st5set
	version 6
	syntax , CLEAR

	version 5
	capture st_is
	version 6
	if _rc==0 {
		di in gr "(data already st/Stata 5)"
	}
	else {
		st_is 2 analysis

		quietly {
			global S_FN
			global S_FNDATE
			keep if _st
			if "`_dta[st_id]'" != "" {
				local id "id(`_dta[st_id]')"
			}
			CopyVar _t t t1 t_1 time time1
			local t "`s(name)'"
			CopyVar _d failure fail f d
			local d "`s(name)'"
			CopyVar _t0 t0 t_0 time0 time_0
			local t0 "`s(name)'"
			version 5
			stset `t' `d', t0(`t0') `id'
			version 6
		}
		di in gr /*
	*/ "(data in memory now appropriate for use with Stata 5 st commands)"
	}
	if _caller() > 5 {
		di
		di in gr /*
*/ `"Note:  Do not forget to type "version 5" to run the old st commands."'
		di in gr _skip(7) "You have not done that yet."
end

program define CopyVar, sclass
	local var `1'
	mac shift
	local typ : type `var'
	GetName `*'
	qui gen `typ' `s(name)' = `var'
end



program define GetName, sclass
	local i 1
	while "``i''"!="" {
		capture confirm new var ``i''
		if _rc == 0 {
			sret local name ``i''
			exit
		}
	}
	di in red "The variables `*' already exist"
	exit 110
end