program define fod2str /* newvar oldvar */
        version 5.0
        local newvar "`1'"
        local oldvar "`2'"

        tempvar tod
        fodstr `tod' `oldvar'
        tempvar mo da ye wrk
        quietly {
                gen `mo' = month(`oldvar')
                gen `da' = day(`oldvar')
                gen `ye' = year(`oldvar')

                twodig `newvar' `da'
                mostr  `wrk' `mo'
                replace `newvar' = `newvar' + `wrk' + string(`ye') + " " /*
                                        */ + `tod'
                replace `newvar' = "" if `tod' == ""
        }
end

program define twodig /* newvar oldvar */
        local newvar "`1'"
        local oldvar "`2'"

        capture drop `newvar'
        qui gen str2 `newvar' = "0" + string(`oldvar') if `oldvar'<10
        qui replace `newvar' = string(`oldvar') if `oldvar'>=10
end

program define mostr /* newvar oldvar */
        local newvar "`1'"
        local oldvar "`2'"

        quietly {
                gen str3 `newvar' = "jan" if `oldvar'==1
                replace `newvar' = "feb" if `oldvar'==2
                replace `newvar' = "mar" if `oldvar'==3
                replace `newvar' = "apr" if `oldvar'==4
                replace `newvar' = "may" if `oldvar'==5
                replace `newvar' = "jun" if `oldvar'==6
                replace `newvar' = "jul" if `oldvar'==7
                replace `newvar' = "aug" if `oldvar'==8
                replace `newvar' = "sep" if `oldvar'==9
                replace `newvar' = "oct" if `oldvar'==10
                replace `newvar' = "nov" if `oldvar'==11
                replace `newvar' = "dec" if `oldvar'==12
        }
end
exit