Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create 50 .dat-files from stata after imputation

    I'm wondering if someone can help me with creating .dat-files from a stata dataset after I applied data-imputation.
    I first imputed data:
    mi register imputed attitude emp_scale serious_sce attrib selfeff colleg collef ///
    leadership decision Harmful Powerimb Repetition Intention

    mi impute mvn attitude emp_scale serious_sce attrib selfeff colleg collef ///
    leadership decision Harmful Powerimb Repetition Intention = liketoint, ///
    add(50) rseed (53421)

    Subsequently, I saved these datafiles as .dta-files with:
    preserve
    forval i=1/50{
    mi extract `i', clear
    save mi_file`i',
    restore, preserve
    }

    However, I would like to create the same files in .dat-file-types.. Is this possible?

    I tried this:
    foreach i in `_mi_m'{
    use "C:\Users\Oct17.dta", clear

    drop if _mi_m !=`i'

    export delimited _mi_m using "C:\Users\\`i'\Oct17.dta",
    replace delimiter(tab) nolabel novar
    }
    but it did not work, neither did this:

    use "C:\Users\16oct.dta", clear

    egen which = group(_mi_m), label
    sum which, meanonly

    forval i=1/`r(max)'{
    local where : label (which) `i'
    export delimited $vars if which==`i' using "C:\Users\`where'/DV/17okt.dat",
    delimiter(tab) nolabel novar replace
    }

    I also tried to replace $vars with "_mi_m", but that did not work either. I do not understand how to export these 50 datafiles and create .dat-files at the same time, is this even possible? Thank you in advance for any help!
Working...
X